public function init()
 {
     parent::init();
     $this->addElement('simpleText', 'path', array('label' => $this->lmsg('pathLabel'), 'value' => $this->_slave->getConfigPath()));
     $this->addElement('textarea', 'config', array('value' => $this->_slave->content(), 'decorators' => [['Callback', ['callback' => [$this, 'decorateConfig']]]]));
     $this->addControlButtons(array('hideLegend' => true, 'sendHidden' => true, 'cancelLink' => pm_Context::getBaseUrl()));
 }
 public function init()
 {
     parent::init();
     $this->addElement('text', 'ip', array('label' => $this->lmsg('ipLabel'), 'value' => '', 'class' => 'f-large-size', 'required' => true, 'validators' => array(array('NotEmpty', true), array('Ip', true))));
     $this->addElement('text', 'port', array('label' => $this->lmsg('portLabel'), 'value' => '953', 'required' => true, 'validators' => array(array('NotEmpty', true), array('Int', true))));
     $this->addElement('select', 'algorithm', array('label' => $this->lmsg('algorithmLabel'), 'multiOptions' => array('hmac-md5' => 'hmac-md5'), 'value' => 'hmac-md5', 'required' => true));
     $this->addElement('text', 'secret', array('label' => $this->lmsg('secretLabel'), 'value' => $this->_getRandomSecret(), 'class' => 'f-large-size', 'required' => true, 'validators' => array(array('NotEmpty', true), array('Callback', true, array(array($this, 'isValidSecret'))))));
     $this->addControlButtons(array('cancelLink' => pm_Context::getBaseUrl()));
 }
Example #3
0
 public function formAction()
 {
     // Display simple text in view
     $this->view->test = 'This is index action for testing module.';
     // Init form here
     $form = new pm_Form_Simple();
     $form->addElement('text', 'exampleText', array('label' => 'Example Text', 'value' => pm_Settings::get('exampleText'), 'required' => true, 'validators' => array(array('NotEmpty', true))));
     $form->addElement('password', 'examplePassword', array('label' => 'Example Password', 'value' => '', 'description' => 'Password: '******'examplePassword'), 'validators' => array(array('StringLength', true, array(5, 255)))));
     $form->addElement('textarea', 'exampleTextarea', array('label' => 'Example TextArea', 'value' => pm_Settings::get('exampleTextarea'), 'class' => 'f-middle-size', 'rows' => 4, 'required' => true, 'validators' => array(array('StringLength', true, array(0, 255)))));
     $form->addElement('simpleText', 'exampleSimpleText', array('label' => 'Example SimpleText', 'escape' => false, 'value' => '<a href="#">Link</a>'));
     $form->addElement('select', 'exampleSelect', array('label' => 'Example Select', 'multiOptions' => array('opt-0' => 'Option 0', 'opt-1' => 'Option 1'), 'value' => pm_Settings::get('exampleSelect'), 'required' => true));
     $form->addElement('radio', 'exampleRadio', array('label' => 'Example Radio', 'multiOptions' => array('opt-0' => 'Option 0', 'opt-1' => 'Option 1'), 'value' => pm_Settings::get('exampleRadio'), 'required' => true));
     $form->addElement('checkbox', 'exampleCheckbox', array('label' => 'Example Checkbox', 'value' => pm_Settings::get('exampleCheckbox')));
     $form->addElement('hidden', 'exampleHidden', array('value' => 'example'));
     $form->addControlButtons(array('cancelLink' => pm_Context::getModulesListUrl()));
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         // Form proccessing here
         pm_Settings::set('exampleText', $form->getValue('exampleText'));
         if ($form->getValue('examplePassword')) {
             pm_Settings::set('examplePassword', $form->getValue('examplePassword'));
         }
         pm_Settings::set('exampleTextarea', $form->getValue('exampleTextarea'));
         pm_Settings::set('exampleSelect', $form->getValue('exampleSelect'));
         pm_Settings::set('exampleRadio', $form->getValue('exampleRadio'));
         pm_Settings::set('exampleCheckbox', $form->getValue('exampleCheckbox'));
         $this->_status->addMessage('info', 'Data was successfully saved.');
         $this->_helper->json(array('redirect' => pm_Context::getBaseUrl()));
     }
     $this->view->form = $form;
 }