Пример #1
0
 /**
  * set the value
  * 
  * @param	string	$value value
  * @return 	\Ameos\AmeosForm\Elements\ElementAbstract this
  */
 public function setValue($value)
 {
     if ($this->configuration['encrypt']) {
         Events::getInstance($this->form->getIdentifier())->registerEvent('form_is_valid', [$this, 'encryptPassword'], ['password' => $value]);
     }
     $this->valueSetted = true;
     $this->value = $value;
     if ($this->form !== false) {
         if ($this->form->getMode() == 'crud/extbase' && $value != '') {
             $method = 'set' . \Ameos\AmeosForm\Utility\StringUtility::camelCase($this->name);
             if (method_exists($this->form->getModel(), $method)) {
                 $this->form->getModel()->{$method}($value);
             }
         }
         if ($this->form->getMode() == 'crud/classic' && $value != '') {
             if ($this->form->hasData($this->name)) {
                 $this->form->setData($this->name, $value);
             }
         }
     }
     return $this;
 }
Пример #2
0
 /**
  * init value from the context
  */
 protected function initValue()
 {
     if ($this->form !== false) {
         if ($this->form->getMode() == 'crud/extbase') {
             $method = 'get' . \Ameos\AmeosForm\Utility\StringUtility::camelCase($this->name);
             if (method_exists($this->form->getModel(), $method)) {
                 $this->setValue($this->form->getModel()->{$method}());
             }
         }
         if ($this->form->getMode() == 'crud/classic') {
             $this->setValue($this->form->getData($this->name));
         }
     }
     if (!$this->valueSetted && isset($this->configuration['defaultValue'])) {
         $this->setValue($this->configuration['defaultValue']);
     }
     return $this;
 }