/**
  * {@inheritDoc}
  * @see \vxPHP\Form\FormElement\FormElement::setValue()
  */
 public function setValue($value = NULL)
 {
     if (isset($value)) {
         parent::setValue($value);
     }
     if (isset($this->selectedOption) && $this->selectedOption->getValue() != $this->getValue()) {
         $this->selectedOption->unselect();
         $this->selectedOption = NULL;
     }
     if (!isset($this->selectedOption)) {
         foreach ($this->options as $o) {
             if ($o->getValue() == $this->getValue()) {
                 $o->select();
                 $this->selectedOption = $o;
                 break;
             }
         }
     }
     return $this;
 }
Exemple #2
0
 private function setElementRequestValue(FormElement $e)
 {
     if (is_null($this->requestValues)) {
         return;
     }
     $name = $e->getName();
     // flagging of checkboxes
     if ($e instanceof \vxPHP\Form\FormElement\CheckboxElement) {
         $e->setChecked(!!$this->requestValues->get($name));
     } else {
         if (!is_null($value = $this->requestValues->get($name))) {
             $e->setValue($value);
         } elseif (isset($this->initFormValues[$name]) && is_null($e->getValue())) {
             $e->setValue($this->initFormValues[$name]);
         }
     }
 }
Exemple #3
0
 /**
  * initialize element with name and value
  * 
  * @param string $name
  * @param string $value
  */
 public function __construct($name, $value = NULL)
 {
     parent::__construct($name, $value);
 }