Differenze tra le versioni di "SfWidgetFormReadOnlyInput"
Jump to navigation
Jump to search
imported>Giorgio (Created page with '<code> <?php /** * sfWidgetFormReadOnlyInput is an input widget with read only option that render a fix text forms * * @author Giorgio Borgonovo borgonovo [at] tavernadelleidee.i...') |
imported>Giorgio |
||
Riga 1: | Riga 1: | ||
− | < | + | <pre> |
<?php | <?php | ||
/** | /** | ||
Riga 30: | Riga 30: | ||
?> | ?> | ||
− | </ | + | </pre> |
[[category:symfony]] | [[category:symfony]] | ||
[[category:php]] | [[category:php]] |
Versione delle 13:18, 4 lug 2010
<?php /** * sfWidgetFormReadOnlyInput is an input widget with read only option that render a fix text forms * * @author Giorgio Borgonovo borgonovo [at] tavernadelleidee.it */ class sfWidgetFormReadOnlyInput extends sfWidgetForm { public function configure($options = array(), $attributes = array()) { $this->addOption('format',"%s"); $this->addOption('default_value'," "); parent::configure($options = array(), $attributes = array()); } public function render($name, $value = null, $attributes = array(), $errors = array()) { if ($this->getAttribute('readonly')=='readonly') { $attributes_reduced = $attributes; unset($attributes_reduced['readonly'],$attributes_reduced['name']); return "<span ".$this->attributesToHtml($attributes_reduced).">".sprintf($this->getOption('format'),($value?$value:($this->getOption('default_value'))))."</span>".$this->renderTag('hidden', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes)); } else { return $this->renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes)); } } } ?>