1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- class sfWidgetFormInputCheckbox extends sfWidgetFormInput
- {
-
- public function __construct($options = array(), $attributes = array())
- {
- $this->addOption('value_attribute_value');
- parent::__construct($options, $attributes);
- }
-
- protected function configure($options = array(), $attributes = array())
- {
- parent::configure($options, $attributes);
- $this->setOption('type', 'checkbox');
- if (isset($attributes['value']))
- {
- $this->setOption('value_attribute_value', $attributes['value']);
- }
- }
-
- public function render($name, $value = null, $attributes = array(), $errors = array())
- {
- if (!is_null($value) && $value !== false)
- {
- $attributes['checked'] = 'checked';
- }
- if (!isset($attributes['value']) && !is_null($this->getOption('value_attribute_value')))
- {
- $attributes['value'] = $this->getOption('value_attribute_value');
- }
- return parent::render($name, null, $attributes, $errors);
- }
- }
|