action_create_edit.rst 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Creating and Editing objects
  2. ============================
  3. .. note::
  4. This document is a stub representing a new work in progress. If you're reading
  5. this you can help contribute, **no matter what your experience level with Sonata
  6. is**. Check out the `issues on Github`_ for more information about how to get involved.
  7. This document will cover the Create and Edit actions. It will cover configuration
  8. of the fields and forms available in these views and any other relevant settings.
  9. Basic configuration
  10. -------------------
  11. To do:
  12. - global (yml) options that affect the create and edit actions
  13. - a note about Routes and how disabling them disables the related action
  14. - using configureFormFields() to set which fields to display
  15. - options available when adding fields, inc custom templates
  16. - link to the field_types document for more details about specific field types
  17. FormGroup options
  18. ~~~~~~~~~~~~~~~~~
  19. When adding a form group to your edit/create form, you may specify some options for the group itself.
  20. - ``collapsed``: unused at the moment
  21. - ``class``: the class for your form group in the admin; by default, the value is set to ``col-md-12``.
  22. - ``fields``: the fields in your form group (you should NOT override this unless you know what you're doing).
  23. - ``description``: to complete
  24. - ``translation_domain``: to complete
  25. To specify options, do as follow:
  26. .. code-block:: php
  27. <?php
  28. MyAdmin extends Admin
  29. {
  30. # ...
  31. public function configureFormFields(FormMapper $formMapper)
  32. {
  33. $formMapper
  34. ->with('Addresses',
  35. array(
  36. 'class' => 'col-md-8',
  37. 'description' => 'Lorem ipsum',
  38. // ...
  39. ))
  40. // ...
  41. ->end()
  42. ;
  43. }
  44. Embedding other Admins
  45. ----------------------
  46. To do:
  47. - how to embed one Admin in another (1:1, 1:M, M:M)
  48. - how to access the right object(s) from the embedded Admin's code
  49. Customizing just one of the actions
  50. -----------------------------------
  51. To do:
  52. - how to create settings/fields that appear on just one of the create/edit views
  53. and any controller changes needed to manage them
  54. .. _`issues on GitHub`: https://github.com/sonata-project/SonataAdminBundle/issues/1519