/** * 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()); }
public function testObject() { $this->object->object()->set(1337); $this->assertEquals(1337, $this->object->object()->value()); }
/** * 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(); } } }