public function init() { $description = $this->createElement('text', 'description'); $description->addValidator('stringLength', false, array(1, 255, 'UTF-8'))->setRequired(true)->setAttrib('class', 'span3')->setLabel('Description')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($description); $this->addElement(IXP_Form_Customer::getPopulatedSelect('custid')); $this->addElement(IXP_Form_Switch::getPopulatedSelect('switchid', \Entities\Switcher::TYPE_CONSOLESERVER)); $port = $this->createElement('text', 'port'); $port->addValidator('stringLength', false, array(1, 255, 'UTF-8'))->setRequired(true)->setLabel('Port')->setAttrib('class', 'span3')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($port); $speed = $this->createElement('text', 'speed'); $speed->addValidator('int')->setLabel('Speed')->addFilter('StringTrim')->setAttrib('class', 'span3')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($speed); $parity = $this->createElement('text', 'parity'); $parity->addValidator('int')->setLabel('Parity')->setAttrib('class', 'span3')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($parity); $stopbits = $this->createElement('text', 'stopbits'); $stopbits->addValidator('int')->setLabel('Stopbits')->setAttrib('class', 'span3')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($stopbits); $flowcontrol = $this->createElement('text', 'flowcontrol'); $flowcontrol->addValidator('int')->setLabel('Flow Control')->setAttrib('class', 'span3')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($flowcontrol); $autobaud = $this->createElement('text', 'autobaud'); $autobaud->addValidator('int')->setAttrib('class', 'span3')->setLabel('Autobaud')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($autobaud); $notes = $this->createElement('textarea', 'notes'); $notes->setLabel('Notes')->setRequired(false)->addFilter(new OSS_Filter_StripSlashes())->setAttrib('cols', 60)->setAttrib('class', 'span3')->setAttrib('rows', 5); $this->addElement($notes); $this->addElement(self::createSubmitElement('submit', _('Add'))); $this->addElement($this->createCancelElement()); }
public function init() { $this->addElement(IXP_Form_Switch::getPopulatedSelect('switchid')); $name = $this->createElement('text', 'name'); $name->setLabel('Name')->setAttrib('class', 'span3'); $this->addElement($name); $type = $this->createElement('select', 'type'); $type->setMultiOptions(\Entities\SwitchPort::$TYPES)->setRegisterInArrayValidator(true)->setLabel('Type')->setAttrib('class', 'span3 chzn-select')->setErrorMessages(array('Please set the port type')); $this->addElement($type); $active = $this->createElement('checkbox', 'active'); $active->setLabel('Active')->setValue('1')->addValidator('InArray', false, [[0, 1]])->addFilter('Int'); $this->addElement($active); $this->addElement(self::createSubmitElement('submit', _('Add'))); $this->addElement($this->createCancelElement()); }
public function init() { $this->setDecorators([['ViewScript', ['viewScript' => 'switch-port/forms/add-ports.phtml']]]); $this->addElement(IXP_Form_Switch::getPopulatedSelect('switchid')); $deftype = $this->createElement('select', 'deftype'); $deftype->setMultiOptions(\Entities\SwitchPort::$TYPES)->setAttrib('class', 'chzn-select span3')->setRegisterInArrayValidator(true)->setLabel('Default Type'); $this->addElement($deftype); $numfirst = $this->createElement('text', 'numfirst'); $numfirst->addValidator('int')->addValidator('greaterThan', false, array(0))->setRequired(true)->setAttrib('class', 'span3')->setLabel('Number of First Port'); $this->addElement($numfirst); $numports = $this->createElement('text', 'numports'); $numports->addValidator('int')->addValidator('greaterThan', false, array(0))->setRequired(true)->setAttrib('class', 'span3')->setLabel('Number of Ports'); $this->addElement($numports); $this->addElement(self::createSubmitElement('submit', _('Add Ports'))); $this->addElement($this->createCancelElement()); }
/** * Enables Fanout ports form elements in customer form * * @param bool $modeEnabled Status of reseller mode enabled or not. * @return IXP_Form_Customer */ public function enableFanoutPort($modeEnabled) { if (!$modeEnabled) { return $this; } $fanout = $this->createElement('checkbox', 'fanout'); $fanout->setLabel('Associate a fanout port')->setCheckedValue('1'); $this->addElement($fanout); $switcher = IXP_Form_Switch::getPopulatedSelect('fn_switchid'); $switcher->setRequired(false)->setAttrib('class', 'chzn-select')->setAttrib('chzn-fix-width', '1')->removeValidator('between'); $this->addElement($switcher); $switchPorts = $this->createElement('select', 'fn_switchportid'); $switchPorts->setRequired(false)->setRegisterInArrayValidator(false)->setLabel('Port')->setAttrib('class', 'chzn-select')->setAttrib('chzn-fix-width', '1')->addValidator('greaterThan', false, array('min' => 1))->setErrorMessages(array('Please select a switch port')); $this->addElement($switchPorts); $monitorindex = $this->createElement('text', 'fn_monitorindex'); $monitorindex->addValidator('int')->setLabel('Monitor Index')->setAttrib('class', 'span3')->addFilter('StringTrim')->addFilter(new OSS_Filter_StripSlashes()); $this->addElement($monitorindex); $preselectSwitchPort = $this->createElement('hidden', 'fn_preselectSwitchPort'); $this->addElement($preselectSwitchPort); $preselectPhysicalInterface = $this->createElement('hidden', 'fn_preselectPhysicalInterface'); $this->addElement($preselectPhysicalInterface); return $this; }
/** * * @param IXP_Form_Switch $form The form object * @param \Entities\Switcher $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->setCabinet($this->getD2EM()->getRepository('\\Entities\\Cabinet')->find($form->getElement('cabinetid')->getValue())); $object->setVendor($this->getD2EM()->getRepository('\\Entities\\Vendor')->find($form->getElement('vendorid')->getValue())); if ($form->getElement('infrastructure')->getValue()) { $object->setInfrastructure($this->getD2EM()->getRepository('\\Entities\\Infrastructure')->find($form->getElement('infrastructure')->getValue())); } return true; }
/** * Enables Fanout ports form elements in customer form * * @param bool $modeEnabled Status of reseller mode enabled or not. * @return IXP_Form_Customer */ public function enableFanoutPort($modeEnabled) { if (!$modeEnabled) { return $this; } $fanout = $this->createElement('checkbox', 'fanout'); $fanout->setLabel('Associate a fanout port')->setCheckedValue('1'); $this->addElement($fanout); $switcher = IXP_Form_Switch::getPopulatedSelect('fn_switchid'); $switcher->setRequired(false)->setAttrib('class', 'chzn-select')->setAttrib('chzn-fix-width', '1')->removeValidator('between'); $this->addElement($switcher); $switchPorts = $this->createElement('select', 'fn_switchportid'); $switchPorts->setRequired(false)->setRegisterInArrayValidator(false)->setLabel('Port')->setAttrib('class', 'chzn-select')->setAttrib('chzn-fix-width', '1')->addValidator('greaterThan', false, array('min' => 1))->setErrorMessages(array('Please select a switch port')); $this->addElement($switchPorts); $preselectSwitchPort = $this->createElement('hidden', 'fn_preselectSwitchPort'); $this->addElement($preselectSwitchPort); $preselectPhysicalInterface = $this->createElement('hidden', 'fn_preselectPhysicalInterface'); $this->addElement($preselectPhysicalInterface); $this->addDisplayGroup(['fn_switchid', 'fn_switchportid', 'fn_preselectSwitchPort', 'fn_preselectPhysicalInterface'], 'fanoutDisplayGroup'); $this->getDisplayGroup('fanoutDisplayGroup')->setLegend('Fanout Port'); return $this; }