Ver Fonte

Merge pull request #1432 from tiagojsag/collection_type_docs

documentation update on sonata_type_collection
Thomas há 12 anos atrás
pai
commit
fdc0542482
1 ficheiros alterados com 20 adições e 6 exclusões
  1. 20 6
      Resources/doc/reference/form_types.rst

+ 20 - 6
Resources/doc/reference/form_types.rst

@@ -24,15 +24,29 @@ sonata_type_collection
 
 
 The ``Collection Type`` is meant to handle creation and edition of model 
 The ``Collection Type`` is meant to handle creation and edition of model 
 collections. Rows can be added and deleted, and your model abstraction layer may
 collections. Rows can be added and deleted, and your model abstraction layer may
-allow you to edit fields inline.
+allow you to edit fields inline. You can use ``type_options`` to pass values
+to the underlying forms.
 
 
-**TIP**: A jQuery event is fired after a row has been added(*sonata-collection-item-added*) or deleted(*sonata-collection-item-deleted*). You can bind to them to trigger some custom javascript imported into your templates(eg: add a calendar widget to a just added date field)
-
-Type configuration
-^^^^^^^^^^^^^^^^^^
+.. code-block:: php
 
 
-todo
+    class AcmeProductAdmin extends Admin
+    {
+        protected function configureFormFields(FormMapper $formMapper)
+        {
+            $formMapper
+                ->add('sales', 'sonata_type_collection', array(
+                    //Prevents the "Delete" option from being displayed
+                    'type_options' => array('delete' => false)
+                ), array(
+                    'edit' => 'inline',
+                    'inline' => 'table',
+                    'sortable' => 'position',
+                ))
+            ;
+        }
+    }
 
 
+**TIP**: A jQuery event is fired after a row has been added(*sonata-collection-item-added*) or deleted(*sonata-collection-item-deleted*). You can bind to them to trigger some custom javascript imported into your templates(eg: add a calendar widget to a just added date field)
 
 
 Field configuration
 Field configuration
 ^^^^^^^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^^^^^