Skip to content
Snippets Groups Projects
Solid-Form.rst 6.19 KiB
Newer Older
.. _solid-form:
solid-form
==========

Receives the URL of a ressource via its ``data-src`` attribute, and
displays a form to edit the resource. If given the URL of a container of
ressources, and displays a creation form to add a resource to the
container.

.. code:: html

Matthieu Fesselier's avatar
Matthieu Fesselier committed
   <solid-form data-src="http://server/todos/"></solid-form>
Matthieu Fesselier's avatar
Matthieu Fesselier committed
Mixins
------

This component uses the following mixins:
   * :ref:`next-mixin <next-mixin>`
   * :ref:`store-mixin <store-mixin>`
   * :ref:`validation-mixin <validation-mixin>`
   * :ref:`widget-mixin <widget-mixin>`
Matthieu Fesselier's avatar
Matthieu Fesselier committed

Please check their documentation to know more about their capabilities.


Specific attributes
-------------------
``fields``
~~~~~~~~~~
   List of the fields used to create the form (by default, all of them are used).

   More details on its use below (in **widget-mixin attributes**).

Matthieu Fesselier's avatar
Matthieu Fesselier committed
``label-[field]``
~~~~~~~~~~~~~~~~~
   When displaying a form, the default labels are the fields names of the model.
   If you want something fancier, you can set this attribute.
   i.e. ``label-username="Your name"``

``naked``
~~~~~~~~~
   When the attribute is set, the submit button will be
   removed. It’s particularly useful to prevent the nested forms to
   display their own submit button.
.. _upload-url-field:
Matthieu Fesselier's avatar
Matthieu Fesselier committed
``upload-url-[field]``
~~~~~~~~~~~~~~~~~~~~~~
Matthieu Fesselier's avatar
Matthieu Fesselier committed
   URL to upload file for field ``[field]``, it
   automatically set ``widget-[field]`` to ``solid-form-file`` if net defined.
   It’s particularly useful with a dropdown field.
.. _submit-button-sf:
``submit-button``
~~~~~~~~~~~~~~~~~
   Text of the submit button of the form.

.. _class-submit-button-sf:
``class-submit-button``
~~~~~~~~~~~~~~~~~~~~~~~
Define the ``class`` of the ``div`` containing the submit button.
   
Matthieu Fesselier's avatar
Matthieu Fesselier committed
``range-[field]``
~~~~~~~~~~~~~~~~~
   URL of a container which list the accepted values
Matthieu Fesselier's avatar
Matthieu Fesselier committed
   for the field ``[field]``. It’s particularly useful with a dropdown
Matthieu Fesselier's avatar
Matthieu Fesselier committed
``enum-[field]``
~~~~~~~~~~~~~~~~
Matthieu Fesselier's avatar
Matthieu Fesselier committed
   *Available from version 0.13*

Matthieu Fesselier's avatar
Matthieu Fesselier committed
   List of values of your choice for the field ``[field]``. 
Manon Bourgognon's avatar
Manon Bourgognon committed
   They have to be filled manually and must be separated by commas. 
   It’s particularly useful with a dropdown or radio field.

   Two formats are possible:
Matthieu Fesselier's avatar
Matthieu Fesselier committed
      * ``enum-[field]="value 1, value 2, value 3"`` : each value will be displayed 
Manon Bourgognon's avatar
Manon Bourgognon committed
      and loaded in value attribute
Matthieu Fesselier's avatar
Matthieu Fesselier committed
      * ``enum-[field]="value1 = a, value2 = b, value3 = c"``: each value will be displayed 
Manon Bourgognon's avatar
Manon Bourgognon committed
      and "a", "b", "c" will be loaded in value attribute.

.. _order-asc-field:
.. _order-desc-field:
Matthieu Fesselier's avatar
Matthieu Fesselier committed
``order-asc-[field]`` or ``order-desc-[field]``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Matthieu Fesselier's avatar
Matthieu Fesselier committed
   Name of the field used to order the range list ``[field]``.
   i.e. ``order-asc-users="username"``
``partial``
~~~~~~~~~~~
   Add this attribute when the form does not include
   all the fields of the resource to update.

.. _required-field:
``required-[field]``
~~~~~~~~~~~~~~~~~~~~
   Add this attribute to make the ``[field]`` required by adding the ``required`` attribute to the input.


Matthieu Fesselier's avatar
Matthieu Fesselier committed
``min-[field]``
~~~~~~~~~~~~~~~
Matthieu Fesselier's avatar
Matthieu Fesselier committed
   Add this attribute for the field ``[field]`` to define its minimum value.
   It works only with ``solid-form-number`` and ``solid-form-time`` widgets.
Matthieu Fesselier's avatar
Matthieu Fesselier committed
``max-[field]``
~~~~~~~~~~~~~~~
Matthieu Fesselier's avatar
Matthieu Fesselier committed
   Add this attribute for the field ``[field]`` to define its maximum value.
   It works only with ``solid-form-number`` and ``solid-form-time`` widgets.
Matthieu Fesselier's avatar
Matthieu Fesselier committed
``pattern-[field]``
Matthieu Fesselier's avatar
Matthieu Fesselier committed
   *Available from version 0.13*

Matthieu Fesselier's avatar
Matthieu Fesselier committed
   Add this attribute for the field ``[field]`` to define a regular expression to check the input's value.
   It works only with a ``solid-form-text`` widget.

Matthieu Fesselier's avatar
Matthieu Fesselier committed
``title-[field]``
~~~~~~~~~~~~~~~~~
Matthieu Fesselier's avatar
Matthieu Fesselier committed
   *Available from version 0.13*

Matthieu Fesselier's avatar
Matthieu Fesselier committed
   Add this attribute for the field ``[field]`` to precise extra information about an element.
   It works only with a ``solid-form-text`` widget.

.. _autocomplete-field-sf:
``autocomplete-[field]``
~~~~~~~~~~~~~~~~~~~~~~~~
   *Available from version 0.15*

Manon Bourgognon's avatar
Manon Bourgognon committed
   Equal to the value ``off``, it cancels the automatic entry of values in the relevant ``[field]``.
   It can be added to ``inputs``, ``textarea`` and ``select``.
``autosave``
~~~~~~~~~~~~
   *Available from version 0.16*

   If the attribute is defined, each change in an input will trigger a request to update the resource.
   This attribute works only when editing resources, not creating them.

``maxlength-[field]``
~~~~~~~~~~~~~~~~~~~~~
   *Available from version 0.16*

   Add this attribute for the field ``[field]`` to define the maximum number of characters that can be typed.
   It works only with ``solid-form-text``, ``solid-form-email`` or ``solid-form-password`` and ``solid-form-textarea`` widgets.
``minlength-[field]``
~~~~~~~~~~~~~~~~~~~~~
   *Available from version 0.16*

   Add this attribute for the field ``[field]`` to define the minimum number of characters that can be typed.
   It works only with ``solid-form-text``, ``solid-form-email`` or ``solid-form-password`` and ``solid-form-textarea`` widgets.
``step-[field]``
~~~~~~~~~~~~~~~~
   *Available from version 0.16*

   Add this attribute for the field ``[field]`` to define the stepping interval number to use as constraint validation. Its based on the ``min-[field]`` value.
   It works with :
      -  ``solid-form-time`` widget : Its value is given in seconds (default value is 60).
      -  ``solid-form-number`` widget : Its default value is 1.

Mixin attributes
-----------------

**From next-mixin :**

.. include:: ../Mixins/next-mixin.rst
   :start-line: 21

**From store-mixin :**

.. include:: ../Mixins/store-mixin.rst
   :start-line: 21

**From validation-mixin :**

.. include:: ../Mixins/validation-mixin.rst
   :start-line: 17

**From widget-mixin :**

.. include:: ../Mixins/widget-mixin.rst
   :start-line: 18


Widgets
-------
By default, the widget used is ``<solid-form-label-text>``. Cf the 
:ref:`Widget <reference>` page for more info.
Matthieu Fesselier's avatar
Matthieu Fesselier committed
Events
-------

``formChange``
~~~~~~~~~~~~~~
   Triggered when the form values change

``save``
~~~~~~~~~~~~~~
   Triggered when the response of the submit has been received successfully