Skip to content

Commit 261f6b2

Browse files
committed
labels in submit buttons + new screenshot
1 parent 01fb9f2 commit 261f6b2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

book/forms.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ from inside a controller::
103103
$form = $this->createFormBuilder($task)
104104
->add('task', 'text')
105105
->add('dueDate', 'date')
106-
->add('save', 'submit')
106+
->add('save', 'submit', array('label' => 'Create Post'))
107107
->getForm();
108108

109109
return $this->render('AcmeTaskBundle:Default:new.html.twig', array(
@@ -128,7 +128,9 @@ In this example, you've added two fields to your form - ``task`` and ``dueDate``
128128
corresponding to the ``task`` and ``dueDate`` properties of the ``Task`` class.
129129
You've also assigned each a "type" (e.g. ``text``, ``date``), which, among
130130
other things, determines which HTML form tag(s) is rendered for that field.
131-
Finally, you added a submit button for submitting the form to the server.
131+
132+
Finally, you added a submit button with a custom label for submitting the form to
133+
the server.
132134

133135
.. versionadded:: 2.3
134136
Support for submit buttons was introduced in Symfony 2.3. Before that, you had
@@ -217,7 +219,7 @@ controller::
217219
$form = $this->createFormBuilder($task)
218220
->add('task', 'text')
219221
->add('dueDate', 'date')
220-
->add('save', 'submit')
222+
->add('save', 'submit', array('label' => 'Create Post'))
221223
->getForm();
222224

223225
$form->handleRequest($request);
@@ -289,8 +291,8 @@ To do this, add a second button with the caption "Save and add" to your form::
289291
$form = $this->createFormBuilder($task)
290292
->add('task', 'text')
291293
->add('dueDate', 'date')
292-
->add('save', 'submit')
293-
->add('saveAndAdd', 'submit')
294+
->add('save', 'submit', array('label' => 'Create Post'))
295+
->add('saveAndAdd', 'submit', array('label' => 'Save and Add'))
294296
->getForm();
295297

296298
In your controller, use the button's

images/book/form-simple.png

34 Bytes
Loading

0 commit comments

Comments
 (0)