leftSection = new HalfPageSection('leftSection'); $this->rightSection = new HalfPageSection('rightSection'); $this->addSection($this->leftSection) ->addSection($this->rightSection); $this->initFields(); } private function initFields() { //Enable Cloud-Init $field = new Switcher('customconfigoption[cloudInit]'); $field->setDescription('tip'); $field->setDefaultValue("on"); $this->addSectionField($field); //Service Username $field = new Switcher('customconfigoption[cloudInitServiceUsername]'); $field->setDescription('tip'); $field->setDefaultValue("on"); $this->addSectionField($field); //Service Password $field = new Switcher('customconfigoption[cloudInitServicePassword]'); $field->setDescription('tip'); $field->setDefaultValue("on"); $this->addSectionField($field); //Service Nameservers $field = new Switcher('customconfigoption[cloudInitServiceNameservers]'); $field->setDescription('tip'); $this->addSectionField($field); //DNS Domain $field = new Text('customconfigoption[searchdomain]'); $field->setDescription('tip'); $this->addSectionField($field); //Default User $field = new Text('customconfigoption[ciuser]'); $field->setDescription('tip'); $this->addSectionField($field); //cicustom $field = new Textarea('customconfigoption[cicustom]'); $field->setDescription('tip'); $this->addSectionField($field); //cloudInitScript $field = new Select('customconfigoption[cloudInitScript]'); $field->setDescription('tip'); $this->addSectionField($field); $this->addFieldsToSections(); } public function addSectionField(BaseField $field) { $this->sectionFields[] = $field; return $this; } private function addFieldsToSections(){ foreach($this->sectionFields as $k => $field){ if($k % 2 == 0 ){ $this->leftSection->addField($field); }else{ $this->rightSection->addField($field); } } unset($this->sectionFields); } }