Пример #1
0
 /**
  * Create a field
  * @param \Runalyze\Configuration\Handle $Handle
  * @param string $label
  * @return \FormularField
  */
 private function createFieldFor(Handle $Handle, $label)
 {
     $Parameter = $Handle->object();
     $Class = 'FormularInput';
     if ($Parameter instanceof SelectRow) {
         $Field = new \FormularSelectDb($Handle->key(), $label, $Handle->value());
         $Field->loadOptionsFrom($Parameter->table(), $Parameter->column());
         return $Field;
     } elseif ($Parameter instanceof Select) {
         $Field = new \FormularSelectBox($Handle->key(), $label, $Handle->value());
         $Field->setOptions($Parameter->options());
         return $Field;
     } elseif ($Parameter instanceof Boolean) {
         $Field = new \FormularCheckbox($Handle->key(), $label, $Handle->value());
         $Field->addHiddenSentValue();
         return $Field;
     }
     return new $Class($Handle->key(), $label, $Handle->object()->valueAsString());
 }
Пример #2
0
 public function testKey()
 {
     $this->assertEquals('key', $this->object->key());
 }
Пример #3
0
 /**
  * Update value from post
  * @param \Runalyze\Configuration\Handle $Handle
  */
 private function updateValueFromPost(Handle $Handle)
 {
     $key = $Handle->key();
     if (isset($_POST[$key]) || isset($_POST[$key . '_sent'])) {
         $value = $Handle->value();
         if ($Handle->object() instanceof Parameter\Bool) {
             $Handle->object()->set(isset($_POST[$key]));
         } else {
             $Handle->object()->setFromString($_POST[$key]);
         }
         if ($value != $Handle->value()) {
             $this->updateValue($Handle);
             $Handle->processOnchangeEvents();
         }
     }
 }