Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • SensioLabs Professional services to help you with Symfony
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by SensioLabs
  1. Home
  2. Documentation
  3. Reference
  4. Types
  5. ResetType Field
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • Inherited Options
    • attr
    • disabled
    • label
    • translation_domain
    • label_translation_parameters
    • attr_translation_parameters
    • row_attr

ResetType Field

Edit this page

ResetType Field

A button that resets all fields to their original values.

Rendered as input reset tag
Parent type ButtonType
Class ResetType

Tip

The full list of options defined and inherited by this form type is available running this command in your app:

1
2
# replace 'FooType' by the class name of your form type
$ php bin/console debug:form FooType

Inherited Options

attr

type: array default: []

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:

1
2
3
4
5
6
use Symfony\Component\Form\Extension\Core\Type\ResetType;
// ...

$builder->add('save', ResetType::class, [
    'attr' => ['class' => 'save'],
]);

disabled

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.

label

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:

1
{{ form_widget(form.save, { 'label': 'Click me' }) }}
1
<?= $view['form']->widget($form['save'], ['label' => 'Click me']) ?>

translation_domain

type: string default: messages

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

label_translation_parameters

type: array default: []

The content of the label option is translated before displaying it, so it can contain translation placeholders. This option defines the values used to replace those placeholders.

Given this translation message:

1
2
# translations/messages.en.yaml
form.order.reset: 'Reset an order to %company%'

You can specify the placeholder values as follows:

1
2
3
4
5
6
7
8
9
use Symfony\Component\Form\Extension\Core\Type\ResetType;
// ...

$builder->add('send', ResetType::class, [
    'label' => 'form.order.reset',
    'label_translation_parameters' => [
        '%company%' => 'ACME Inc.',
    ],
]);

The label_translation_parameters option of buttons is merged with the same option of its parents, so buttons can reuse and/or override any of the parent placeholders.

attr_translation_parameters

type: array default: []

The content of the title and placeholder values defined in the attr option is translated before displaying it, so it can contain translation placeholders. This option defines the values used to replace those placeholders.

Given this translation message:

1
2
3
# translations/messages.en.yaml
form.order.id.placeholder: 'Enter unique identifier of the order to %company%'
form.order.id.title: 'This will be the reference in communications with %company%'

You can specify the placeholder values as follows:

1
2
3
4
5
6
7
8
9
$builder->add('id', null, [
    'attr' => [
        'placeholder' => 'form.order.id.placeholder',
        'title' => 'form.order.id.title',
    ],
    'attr_translation_parameters' => [
        '%company%' => 'ACME Inc.',
    ],
]);

The attr_translation_parameters option of children fields is merged with the same option of their parents, so children can reuse and/or override any of the parent placeholders.

row_attr

type: array default: []

An associative array of the HTML attributes added to the element which is used to render the form type row:

1
2
3
$builder->add('body', TextareaType::class, [
    'row_attr' => ['class' => 'text-editor', 'id' => '...'],
]);

See also

Use the attr option if you want to add these attributes to the form type widget element.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:

    Symfony 6.2 is backed by

    Symfony 6.2 is backed by

    Show your Sylius expertise

    Show your Sylius expertise

    Code consumes server resources. Blackfire tells you how

    Code consumes server resources. Blackfire tells you how

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of Phillip Look, a Symfony contributor

    Thanks Phillip Look (@plook) for being a Symfony contributor

    1 commit • 26 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Deployed on

    Follow Symfony

    Search by Algolia