/** * Add all fields to the form and set form specific attributes. */ public function initialize() { $this->_action = 'general'; $title = new Text('title'); $title->setLabel('Title'); $title->setFilters(array('striptags', 'string')); $title->setAttributes(array('class' => 'form-control')); $title->setDefault($this->_config->application->title); $title->addValidators(array(new PresenceOf(array()))); $cryptKey = new Text('cryptkey'); $cryptKey->setLabel('Cryptkey'); $cryptKey->setFilters(array('striptags', 'string')); $cryptKey->setAttributes(array('class' => 'form-control')); $cryptKey->setDefault($this->_config->application->phalconCryptKey); $cryptKey->addValidators(array(new PresenceOf(array()))); $bgcolor = new Select('bgcolor', array('blackbg' => 'Black', 'whitebg' => 'White'), array('useEmpty' => false)); $bgcolor->setLabel('Background color'); $bgcolor->setDefault($this->_config->application->background); $debug = new Check('debug'); $debug->setLabel('debug'); $debug->setAttributes(array('checked' => $this->_config->application->debug == '1' ? 'checked' : null)); $this->add($title); $this->add($bgcolor); $this->add($cryptKey); $this->add($debug); }
public function initialize() { $this->_action = 'devices_add'; $name = new Text('name'); $name->setLabel('Devicename'); $name->setFilters(array('striptags', 'string')); $name->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off')); $ip = new Text('ip'); $ip->setLabel('IP'); $ip->setFilters(array('striptags', 'string')); $ip->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off')); $mac = new Text('mac'); $mac->setLabel('MAC'); $mac->setFilters(array('striptags', 'string')); $mac->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off')); $webtemp = new Text('webtemp'); $webtemp->setLabel('Webtemp path'); $webtemp->setFilters(array('striptags', 'string')); $webtemp->setAttributes(array('class' => 'form-control', 'autocomplete' => 'off')); $shutdownMethod = new Select('shutdown_method', array('none' => 'None', 'rpc' => 'RPC'), array('useEmpty' => false)); $shutdownMethod->setLabel('Shutdown method'); $showDasboard = new Check('show_on_dashboard'); $showDasboard->setLabel('Show on dashboard'); $showDasboard->setAttributes(array('class' => 'form-control')); $this->add($name); $this->add($ip); $this->add($mac); $this->add($webtemp); $this->add($shutdownMethod); $this->add($showDasboard); }
private function addFIelds($device) { $name = new Text('devices[' . $device->id . '][name]'); $name->setLabel('Devicename'); $name->setFilters(array('striptags', 'string')); $name->setAttributes(array('class' => 'form-control')); $name->setDefault($device->name); $name->addValidators(array(new PresenceOf(array()))); $ip = new Text('devices[' . $device->id . '][ip]'); $ip->setLabel('IP'); $ip->setFilters(array('striptags', 'string')); $ip->setAttributes(array('class' => 'form-control')); $ip->setDefault($device->ip); $ip->addValidator(new Regex(array('pattern' => '/^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/'))); $mac = new Text('devices[' . $device->id . '][mac]'); $mac->setLabel('MAC'); $mac->setFilters(array('striptags', 'string')); $mac->setAttributes(array('class' => 'form-control')); $mac->setDefault($device->mac); $mac->addValidator(new Regex(array('pattern' => '/^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$/'))); $webtemp = new Text('devices[' . $device->id . '][webtemp]'); $webtemp->setLabel('Webtemp path'); $webtemp->setFilters(array('striptags', 'string')); $webtemp->setAttributes(array('class' => 'form-control')); $webtemp->setDefault($device->webtemp); $shutdownMethod = new Select('devices[' . $device->id . '][shutdown_method]', array('none' => 'None', 'rpc' => 'RPC'), array('useEmpty' => false)); $shutdownMethod->setDefault($device->shutdown_method); $showDasboard = new Check('devices[' . $device->id . '][show_on_dashboard]'); $showDasboard->setLabel('Show on dashboard'); $showDasboard->setFilters(array('striptags', 'int')); $showDasboard->setAttributes(array('class' => 'form-control')); $showDasboard->setDefault($device->show_on_dashboard); $id = new Hidden('devices[' . $device->id . '][id]'); $id->setDefault($device->id); $this->add($name); $this->add($ip); $this->add($mac); $this->add($webtemp); $this->add($shutdownMethod); $this->add($showDasboard); $this->add($id); }