/** * 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()); }
/** * Add condition field with chosen * @param string $name * @param string $table * @param string $key * @param string $label * @param string $placeholder */ private function addConditionFieldWithChosen($name, $table, $key, $label, $placeholder) { if ($table == 'weather') { $Field = new TrainingSelectWeather($name, $label); } else { $Field = new FormularSelectDb($name, $label); $Field->loadOptionsFrom($table, $key); } $Field->addCSSclass('chzn-select full-size'); $Field->setMultiple(); $Field->addAttribute('data-placeholder', $placeholder); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W50_IN_W33); $this->Fieldset->addField($Field); }