public function render($name, $value = null, $attributes = array(), $errors = array()) { if ($value == '0') { $value = null; } return parent::render($name, $value, $attributes, $errors); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { if ($this->getOption('inner_label')) { return '<label class="checkbox">' . parent::render($name, $value, $attributes, $errors) . $this->escapeOnce($this->getOption('inner_label')) . '<label>'; } return parent::render($name, $value, $attributes, $errors); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $hidden = new sfWidgetFormInputHidden(); $hidden = $hidden->render($name, 0, array('id' => false)); $value = $value == 0 ? null : $value; $attributes['value'] = 1; return $hidden . parent::render($name, $value, $attributes, $errors); }
/** * Renders the widget. * * @param string $name The element name * @param string $value The this widget is checked if value is not null * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes * @param array $errors An array of errors for the field * * @return string An HTML tag string * * @see sfWidgetForm */ public function render($name, $value = null, $attributes = array(), $errors = array()) { if (null !== $value && $value !== false && $value !== "") { $attributes['checked'] = 'checked'; } if (!isset($attributes['value']) && null !== $this->getOption('value_attribute_value')) { $attributes['value'] = $this->getOption('value_attribute_value'); } return parent::render($name, null, $attributes, $errors); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $attributes = array_merge($attributes, array('data-on' => self::$LABELS[1], 'data-off' => self::$LABELS[0])); parent::render($name, $value, $attributes, $errors); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { return parent::render($name, !empty($value), $attributes, $errors); }
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(7); $w = new sfWidgetFormInputCheckbox(); // ->render() $t->diag('->render()'); $t->is($w->render('foo', 1), '<input type="checkbox" name="foo" checked="checked" id="foo" />', '->render() renders the widget as HTML'); $t->is($w->render('foo', null), '<input type="checkbox" name="foo" id="foo" />', '->render() renders the widget as HTML'); $t->is($w->render('foo', false), '<input type="checkbox" name="foo" id="foo" />', '->render() renders the widget as HTML'); $t->is($w->render('foo', 0, array('value' => '0')), '<input type="checkbox" name="foo" value="0" checked="checked" id="foo" />', '->render() renders the widget as HTML'); $w = new sfWidgetFormInputCheckbox(array(), array('value' => 'bar')); $t->is($w->render('foo', null), '<input value="bar" type="checkbox" name="foo" id="foo" />', '->render() renders the widget as HTML'); $t->is($w->render('foo', null, array('value' => 'baz')), '<input value="baz" type="checkbox" name="foo" id="foo" />', '->render() renders the widget as HTML'); $t->is($w->render('foo', 'bar'), '<input value="bar" type="checkbox" name="foo" checked="checked" id="foo" />', '->render() renders the widget as HTML');
public function render($name, $value = null, $attributes = array(), $errors = array()) { $attributes = array_merge($attributes); parent::render($name, $value, $attributes, $errors); }