Exemplo n.º 1
0
 /**
  * Form for disabling user authentication while using a default user
  *
  * @param array $values
  * @return Form
  */
 protected function getAuthenticationForm($values = array())
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'settings/authentication');
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Checkbox('disable_authentication');
     $field->setCheckedValue(1);
     $field->setRequired(false);
     $field->setLabel('Disable Authentication?');
     $field->setContainerClass('form-group');
     $field->setValue(0);
     if (isset($values['state'])) {
         $field->setValue((int) $values['state']);
     }
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue('Save »');
     $field->setClass('btn btn-success pull-right');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
Exemplo n.º 2
0
 public function testElements()
 {
     $e = new Form\Element\Button();
     $this->assertTrue($e->validate());
     $this->assertTrue(strpos($e->render(), 'button') !== false);
     $e = new Form\Element\Checkbox();
     $e->setCheckedValue('ten');
     $this->assertTrue($e->getCheckedValue() == 'ten');
     $this->assertTrue(strpos($e->render(), 'checkbox') !== false);
     $this->assertTrue(strpos($e->render(), 'checked') === false);
     $e->setValue(true);
     $this->assertTrue(strpos($e->render(), 'checked') !== false);
     $e->setValue('ten');
     $this->assertTrue(strpos($e->render(), 'checked') !== false);
     $e->setValue('fail');
     $this->assertTrue(strpos($e->render(), 'checked') === false);
     $e = new Form\Element\CheckboxGroup();
     $this->assertTrue(strpos($e->render(), 'group') !== false);
     $e = new Form\ControlGroup();
     $this->assertTrue(strpos($e->render(), 'group') !== false);
     $e = new Form\Element\Email();
     $this->assertTrue(strpos($e->render(), 'email') !== false);
     $e = new Form\Element\Select();
     $e->setOptions(array('key' => 'Val'));
     $html = $e->render();
     $this->assertTrue(strpos($html, 'select') !== false);
     $this->assertTrue(strpos($html, 'option') !== false);
     $this->assertTrue(strpos($html, 'key') !== false);
     $this->assertTrue(strpos($html, 'Val') !== false);
     $e = new Form\Element\Submit();
     $this->assertTrue($e->validate());
     $this->assertTrue(strpos($e->render(), 'submit') !== false);
     $e = new Form\Element\Text();
     $e->setValue('test');
     $this->assertTrue(strpos($e->render(), 'test') !== false);
     $e = new Form\Element\TextArea();
     $e->setRows(10);
     $this->assertTrue(strpos($e->render(), '10') !== false);
     $e = new Form\Element\Url();
     $this->assertTrue(strpos($e->render(), 'url') !== false);
 }
Exemplo n.º 3
0
 protected function getEmailForm($values = array())
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'settings/email');
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Text('smtp_address');
     $field->setRequired(false);
     $field->setLabel('SMTP Server');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue('localhost');
     $form->addField($field);
     $field = new Form\Element\Text('smtp_port');
     $field->setRequired(false);
     $field->setPattern('[0-9]+');
     $field->setLabel('SMTP Port');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue(25);
     $form->addField($field);
     $field = new Form\Element\Text('smtp_username');
     $field->setRequired(false);
     $field->setLabel('SMTP Username');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Text('smtp_password');
     $field->setRequired(false);
     $field->setLabel('SMTP Password');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('from_address');
     $field->setRequired(false);
     $field->setLabel('From Email Address');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('default_mailto_address');
     $field->setRequired(false);
     $field->setLabel('Default Notification Address');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Checkbox('smtp_encryption');
     $field->setCheckedValue(1);
     $field->setRequired(false);
     $field->setLabel('Use SMTP encryption?');
     $field->setContainerClass('form-group');
     $field->setValue(1);
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue('Save »');
     $field->setClass('btn btn-success pull-right');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }