Skip to content

Commit 11c21db

Browse files
Added more details about the FormView object
1 parent f1355d2 commit 11c21db

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

book/forms.rst

+28-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ specify it:
688688

689689
<?php echo $view['form']->label($form['task'], 'Task Description') ?>
690690

691-
Finally, some field types have additional rendering options that can be passed
691+
Some field types have additional rendering options that can be passed
692692
to the widget. These options are documented with each type, but one common
693693
options is ``attr``, which allows you to modify attributes on the form element.
694694
The following would add the ``task_field`` class to the rendered input text
@@ -706,6 +706,33 @@ field:
706706
'attr' => array('class' => 'task_field'),
707707
)) ?>
708708

709+
If you need to render form fields "by hand" then you can access individual
710+
values for fields such as the ``id``, ``name`` and ``label``. For example
711+
to get the ``id``:
712+
713+
.. configuration-block::
714+
715+
.. code-block:: html+jinja
716+
717+
{{ form.task.vars.id }}
718+
719+
.. code-block:: html+php
720+
721+
<?php echo $form['task']->get('id') ?>
722+
723+
To get the value used for the form field's name attribute you need to use
724+
the ``full_name`` value:
725+
726+
.. configuration-block::
727+
728+
.. code-block:: html+jinja
729+
730+
{{ form.task.vars.full_name }}
731+
732+
.. code-block:: html+php
733+
734+
<?php echo $form['task']->get('full_name') ?>
735+
709736
Twig Template Function Reference
710737
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
711738

0 commit comments

Comments
 (0)