发布于 2015-08-27 16:47:19 | 169 次阅读 | 评论: 0 | 来源: 网络整理
2.3 新版功能: The button
type was introduced in Symfony 2.3
A simple, non-responsive button.
Rendered as | button tag |
Inherited options | |
Parent type | none |
Class | ButtonType |
The following options are defined in the
BaseType
class.
The BaseType
class is the parent class for both the button
type and
the form type, but it is not part of
the form type tree (i.e. it can not be used as a form type on its own).
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'),
));
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:
{{ form_widget(form.save, { 'label': 'Click me' }) }}
<?php echo $view['form']->widget($form['save'], array('label' => 'Click me')) ?>
type: string
default: messages
This is the translation domain that will be used for any labels or options that are rendered for this button.