public function init() { $name = $this->createElement('text', 'name'); $name->addValidator('stringLength', false, array(1, 255, 'UTF-8'))->setAttrib('class', 'span3')->setRequired(true)->setLabel('Name')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($name); $hostname = $this->createElement('text', 'hostname'); $hostname->addValidator('stringLength', false, array(1, 255, 'UTF-8'))->setAttrib('class', 'span3')->setRequired(true)->setLabel('Hostname')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($hostname); $switchtype = $this->createElement('select', 'switchtype'); $switchtype->setMultiOptions(\Entities\Switcher::$TYPES)->setAttrib('class', 'span3 chzn-select')->setRegisterInArrayValidator(true)->addValidator('greaterThan', true, array(0))->setLabel('Type')->setErrorMessages(array('Please set the switch type')); $this->addElement($switchtype); $this->addElement(IXP_Form_Cabinet::getPopulatedSelect('cabinetid')); $infrastructure = IXP_Form_Infrastructure::getPopulatedSelect('infrastructure'); $this->addElement($infrastructure); $snmppasswd = $this->createElement('text', 'snmppasswd'); $snmppasswd->addValidator('stringLength', false, array(1, 255, 'UTF-8'))->setAttrib('class', 'span3')->setLabel('SNMP Community')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($snmppasswd); $active = $this->createElement('checkbox', 'active'); $active->setLabel('Active?')->setCheckedValue('1')->setUncheckedValue('0')->setValue('1'); $this->addElement($active); $this->addElement(self::createSubmitElement('submit', _('Next'))); $this->addElement($this->createCancelElement('cancel', OSS_Utils::genUrl('switch', 'list'))); $manualAdd = new OSS_Form_Element_Buttonlink('manualAdd'); $manualAdd->setAttrib('href', OSS_Utils::genUrl('switch', 'add'))->setAttrib('label', _('Manual / Non-SNMP Add')); $this->addElement($manualAdd); }
public function init() { $name = $this->createElement('text', 'name'); $name->addValidator('stringLength', false, array(1, 255, 'UTF-8'))->setRequired(true)->setLabel('Name')->setAttrib('class', 'span3')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($name); $this->addElement(IXP_Form_Customer::getPopulatedSelect('custid')); $this->addElement(IXP_Form_Cabinet::getPopulatedSelect('cabinetid')); $descr = $this->createElement('textarea', 'descr'); $descr->setLabel(_('Description'))->setRequired(false)->addFilter(new OSS_Filter_StripSlashes())->setAttrib('cols', 60)->setAttrib('class', 'span3')->setAttrib('rows', 5); $this->addElement($descr); $this->addElement(self::createSubmitElement('submit', _('Add'))); $this->addElement($this->createCancelElement()); }
/** * * @param IXP_Form_Cabinet $form The form object * @param \Entities\Cabinet $object The Doctrine2 entity (being edited or blank for add) * @param bool $isEdit True of we are editing an object, false otherwise * @return void */ protected function addPostValidate($form, $object, $isEdit) { $object->setLocation($this->getD2EM()->getRepository('\\Entities\\Location')->find($form->getElement('locationid')->getValue())); return true; }