/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Sample usage: $this->widgetSchema['type'] = new sfWidgetFormChoiceOrPlain(array('choices' => sfConfig::get('types'), 'plain' => !$this->getObject()->isNew())); * * @author Luã de Souza */ class sfWidgetFormChoiceOrPlain extends sfWidgetFormChoice { { parent::configure($options, $attributes); $this->addOption('plain', false); } { if ($this->getOption('plain')) { $hidden = new sfWidgetFormInputHidden(); $choices = $this->getOption('choices'); $label = $value ? $choices[$value] : $value; return $this->renderContentTag('div', $label, $attributes) . $hidden->render($name, $value); } else { if ($this->getOption('multiple')) { $attributes['multiple'] = 'multiple'; { $name .= '[]'; } } if (!$this->getOption('renderer') && !$this->getOption('renderer_class') && $this->getOption('expanded')) { } return parent::getRenderer()->render($name, $value, $attributes, $errors); } } }
Comments
