Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed May 12, 2023
1 parent accfef1 commit 91c6b8e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 74 deletions.
33 changes: 7 additions & 26 deletions docs/reference/conditional_validation.rst
Expand Up @@ -72,34 +72,15 @@ Using this Validator

Add the ``InlineConstraint`` class constraint to your bundle's validation configuration:

.. configuration-block::
.. code-block:: yaml
.. code-block:: yaml
# src/Application/Sonata/PageBundle/Resources/config/validation.yaml
# src/Application/Sonata/PageBundle/Resources/config/validation.yaml
Application\Sonata\PageBundle\Entity\Block:
constraints:
- Sonata\Form\Validator\Constraints\InlineConstraint:
service: sonata.page.cms.page
method: validateBlock
.. code-block:: xml
<!-- src/Application/Sonata/PageBundle/Resources/config/validation.xml -->
<?xml version="1.0" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="Application\Sonata\PageBundle\Entity\Block">
<constraint name="Sonata\Form\Validator\Constraints\InlineConstraint">
<option name="service">sonata.page.cms.page</option>
<option name="method">validateBlock</option>
</constraint>
</class>
</constraint-mapping>
Application\Sonata\PageBundle\Entity\Block:
constraints:
- Sonata\Form\Validator\Constraints\InlineConstraint:
service: sonata.page.cms.page
method: validateBlock
There are two important options:

Expand Down
62 changes: 27 additions & 35 deletions docs/reference/form_types.rst
Expand Up @@ -13,20 +13,18 @@ This form type reads ``JMSSerializer`` serialization class metadata and uses ``D

All you have to do is to define a form type service for each entity for which you want to use a form type, like this:

.. configuration-block::
.. code-block:: xml
.. code-block:: xml
<!-- config/services.xml -->
<!-- config/services.xml -->
<service id="my.custom.form.type.comment" class="Sonata\Form\Type\DoctrineORMSerializationType">
<argument type="service" id="jms_serializer.metadata_factory"/>
<argument type="service" id="doctrine"/>
<argument>my_custom_form_type_comment</argument>
<argument>App\Entity\Comment</argument>
<argument>a_serialization_group</argument>
<tag name="form.type" alias="my_custom_form_type_comment"/>
</service>
<service id="my.custom.form.type.comment" class="Sonata\Form\Type\DoctrineORMSerializationType">
<argument type="service" id="jms_serializer.metadata_factory"/>
<argument type="service" id="doctrine"/>
<argument>my_custom_form_type_comment</argument>
<argument>App\Entity\Comment</argument>
<argument>a_serialization_group</argument>
<tag name="form.type" alias="my_custom_form_type_comment"/>
</service>
The service definition should contain the following arguments:

Expand Down Expand Up @@ -230,17 +228,15 @@ Now, you want to create a form type to expose those values::

This can be done by declaring a new service:

.. configuration-block::

.. code-block:: xml
.. code-block:: xml
<service id="sonata.order.form.status_type" class="Sonata\Form\Type\StatusType">
<tag name="form.type"/>
<service id="sonata.order.form.status_type" class="Sonata\Form\Type\StatusType">
<tag name="form.type"/>
<argument>%sonata.order.order.class%</argument>
<argument>getStatusList</argument>
<argument>sonata_order_status</argument>
</service>
<argument>%sonata.order.order.class%</argument>
<argument>getStatusList</argument>
<argument>sonata_order_status</argument>
</service>
And the type can now be used::

Expand Down Expand Up @@ -282,15 +278,13 @@ They will allow you to have a JS date picker onto your form fields as follows:

In order to use them, you'll need to perform a bit of setup:

.. configuration-block::
.. code-block:: yaml
.. code-block:: yaml
# config/packages/twig.yaml
# config/packages/twig.yaml
twig:
form_themes:
- '@SonataForm/Form/datepicker.html.twig'
twig:
form_themes:
- '@SonataForm/Form/datepicker.html.twig'
In your layout, you'll need to add the assets dependencies (feel free to
adapt this to your needs, for instance, to use with assetic):
Expand Down Expand Up @@ -398,15 +392,13 @@ This is HTML5 input type color.

In order to use it, you'll need to perform a bit of setup:

.. configuration-block::

.. code-block:: yaml
.. code-block:: yaml
# config/packages/twig.yaml
# config/packages/twig.yaml
twig:
form_themes:
- '@SonataForm/Form/color.html.twig'
twig:
form_themes:
- '@SonataForm/Form/color.html.twig'
Finally, in your form, you may use the form type as follows::

Expand Down
22 changes: 9 additions & 13 deletions docs/reference/installation.rst
Expand Up @@ -31,27 +31,23 @@ horizontal style.
If you are using the horizontal style, you will need to configure the
corresponding configuration node accordingly:

.. configuration-block::
.. code-block:: yaml
.. code-block:: yaml
# config/packages/sonata_form.yaml
# config/packages/sonata_form.yaml
sonata_form:
form_type: horizontal
sonata_form:
form_type: horizontal
If you are using ``jms/serializer`` subscribing methods you will need to configure the
return formats:

.. configuration-block::

.. code-block:: yaml
.. code-block:: yaml
# config/packages/sonata_form.yaml
# config/packages/sonata_form.yaml
sonata_form:
serializer:
formats: ['json', 'xml', 'yml']
sonata_form:
serializer:
formats: ['json', 'xml', 'yml']
Please note that if you are using the admin bundle, this is actually optional:
The core bundle extension will detect if the configuration node that deals with
Expand Down

0 comments on commit 91c6b8e

Please sign in to comment.