Warning: You are browsing the documentation for Symfony 2.8, which is no longer maintained.

Read the updated version of this page for Symfony 5.3 (the current stable version).

SubmitType Field

SubmitType Field

New in version 2.3: The SubmitType type was introduced in Symfony 2.3.

A submit button.

Rendered as button submit tag
Inherited options
Parent type ButtonType
Class Symfony\Component\Form\Extension\Core\Type\SubmitType

The Submit button has an additional method isClicked() that lets you check whether this button was used to submit the form. This is especially useful when a form has multiple submit buttons:

if ($form->get('save')->isClicked()) {
    // ...

Inherited Options


type: array default: array()

If you want to add extra attributes to the HTML representation of the button, you can use attr option. It’s an associative array with HTML attribute as a key. This can be useful when you need to set a custom class for the button:

use Symfony\Component\Form\Extension\Core\Type\SubmitType;
// ...

$builder->add('save', SubmitType::class, array(
    'attr' => array('class' => 'save'),


type: boolean default: false

If you don’t want a user to be able to click a button, you can set the disabled option to true. It will not be possible to submit the form with this button, not even when bypassing the browser and sending a request manually, for example with cURL.


type: string default: The label is “guessed” from the field name

Sets the label that will be displayed on the button. The label can also be directly set inside the template:

  • Twig
    {{ form_widget(form.save, { 'label': 'Click me' }) }}
  • PHP
    <?php echo $view['form']->widget($form['save'], array('label' => 'Click me')) ?>


New in version 2.6: The label_format option was introduced in Symfony 2.6.

type: string default: null

Configures the string used as the label of the field, in case the label option was not set. This is useful when using keyword translation messages.

If you’re using keyword translation messages as labels, you often end up having multiple keyword messages for the same label (e.g. profile_address_street, invoice_address_street). This is because the label is build for each “path” to a field. To avoid duplicated keyword messages, you can configure the label format to a static value, like:

// ...
$profileFormBuilder->add('address', new AddressType(), array(
    'label_format' => 'form.address.%name%',

$invoiceFormBuilder->add('invoice', new AddressType(), array(
    'label_format' => 'form.address.%name%',

This option is inherited by the child types. With the code above, the label of the street field of both forms will use the form.address.street keyword message.

Two variables are available in the label format:

A unique identifier for the field, consisting of the complete path to the field and the field name (e.g. profile_address_street);
The field name (e.g. street).

The default value (null) results in a “humanized” version of the field name.


The label_format option is evaluated in the form theme. Make sure to update your templates in case you customized form theming.


type: string default: messages

This is the translation domain that will be used for any labels or options that are rendered for this button.


type: array default: null

When your form contains multiple submit buttons, you can change the validation group based on the button which was used to submit the form. Imagine a registration form wizard with buttons to go to the previous or the next step:

use Symfony\Component\Form\Extension\Core\Type\SubmitType;
// ...

$form = $this->createFormBuilder($user)
    ->add('previousStep', SubmitType::class, array(
        'validation_groups' => false,
    ->add('nextStep', SubmitType::class, array(
        'validation_groups' => array('Registration'),

The special false ensures that no validation is performed when the previous step button is clicked. When the second button is clicked, all constraints from the “Registration” are validated.

See also

You can read more about this in How to Choose Validation Groups Based on the Submitted Data.

Form Variables

Variable Type Usage
clicked boolean Whether the button is clicked or not.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.