SfWidgetFormReadOnlyInput
Versione del 4 lug 2010 alle 13:18 di imported>Giorgio
<?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)); } } } ?>