概述 快速入门 教程 手册 最佳实践 组件 参考 贡献

发布于 2015-08-27 16:39:34 | 158 次阅读 | 评论: 0 | 来源: 网络整理

2.3 新版功能: The reset type was introduced in Symfony 2.3

A button that resets all fields to their original values.

Rendered as input reset tag
Inherited options
Parent type button
Class ResetType

Inherited Options

attr

type: array default: Empty 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:

$builder->add('save', 'button', array(
    'attr' => array('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:

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

label_attr

type: array default: array()

Sets the HTML attributes for the <label> element, which will be used when rendering the label for the field. It’s an associative array with HTML attribute as a key. This attributes can also be directly set inside the template:

  • Twig
    {{ form_label(form.name, 'Your name', {'label_attr': {'class': 'CUSTOM_LABEL_CLASS'}}) }}
    
  • PHP
    echo $view['form']->label(
        $form['name'],
        'Your name',
        array('label_attr' => array('class' => 'CUSTOM_LABEL_CLASS'))
    );
    

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.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务