SfWidgetFormReadOnlyInput

Da Caos per caso.
Versione del 4 lug 2010 alle 13:18 di 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...')
(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)
Jump to navigation Jump to search

<?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 "attributesToHtml($attributes_reduced).">".sprintf($this->getOption('format'),($value?$value:($this->getOption('default_value'))))."".$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));
   }
 }

}

?>