瀏覽代碼

documentation update on sonata_type_collection

Tiago Garcia 12 年之前
父節點
當前提交
9e3dee73d9
共有 1 個文件被更改,包括 20 次插入6 次删除
  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 
 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
 ^^^^^^^^^^^^^^^^^^^