Exemplo n.º 1
0
 /**
  * create the form
  */
 function __construct()
 {
     parent::__construct();
     $this->oAddress = self::address('address')->setLabel('address');
     $this->oChained = self::chainedDropdowns('chained')->setLabel('chained dropdown')->setData(array(0 => array('one' => 1, 'two' => 3, 'three' => 6), 1 => array('one' => 1, 'two' => 4, 'three' => 7), 2 => array('one' => 2, 'two' => 5, 'three' => 8)));
     $this->oCheckbox = self::checkbox('checkbox', 'value')->setLabel('single checkbox');
     $this->oCheckboxes = self::checkbox('checkboxes')->setLabel('multiple checkboxes')->appendOptions(array(1 => 'one', 'two', 'three'));
     $this->oColor = self::color('color')->setLabel('color');
     $this->oDate = self::date('date')->setLabel('date');
     $this->oDateRange = self::dateRange('dateRange', date('d-m-Y'), date('d-m-Y'))->setLabel('date range');
     $this->oDropdown = self::dropdown('dropdown')->appendOptions(array(1 => 'one', 'two', 'three'))->setLabel('dropdown');
     $this->oEmail = self::email('email', '*****@*****.**')->setLabel('email');
     $this->oFile = self::file('file')->setLabel('file');
     $this->oHidden = self::hidden('hidden')->setLabel('hidden');
     $this->oMonth = self::month('month')->setLabel('month');
     $this->oMonthRange = self::monthRange('monthRange', '2013-01', '2013-09')->setLabel('month range');
     $this->oNumber = self::number('number')->setLabel('number');
     $this->oPassword = self::password('password')->setLabel('password');
     $this->oRadio = self::radio('radio')->appendOptions(array(1 => 'one', 'two', 'three'))->setLabel('radio');
     $this->oRange = self::range('range')->setLabel('range');
     $this->oSearch = self::search('search')->setLabel('search');
     $this->oTel = self::tel('tel')->setLabel('tel');
     $this->oText = self::text('text', 'value')->setLabel('text');
     $this->oTextarea = self::textarea('textarea', 'value')->setLabel('textarea');
     $this->oUrl = self::url('url')->setLabel('url');
     $this->oWeek = self::week('week', '2013-44')->setLabel('week');
     $this->oWeekRange = self::weekRange('weekRange', '2013-01', '2013-38')->setLabel('week range');
     $this->oButton = self::button('button', 'Button')->setLabel('button');
     $this->oInputButton = self::inputButton('inputButton', 'Input Button')->setLabel('input button');
     $this->oImage = self::image('image')->setAlt('Image')->setSrc('https://2.gravatar.com/avatar/f65305395860df24db70a8dc6aeddc2f')->setLabel('image');
     $this->oReset = self::reset('reset', 'Reset')->setLabel('reset');
     $this->oSubmit = self::submit('submit', 'Submit')->setLabel('submit');
 }
Exemplo n.º 2
0
 /**
  * construct AddressInput object
  * @param string $name
  * @param string $value
  */
 function __construct($name, $value = null)
 {
     parent::__construct($name, $value);
     $translator = Translator::getInstance();
     // create the text inputs
     // NOTE: values must be the same as the titles for the jquery script
     $postcode = $translator->get('inputs.postal-code');
     $this->postcode = Form::text($name . '-' . $postcode)->setPlaceholder(str_replace('-', ' ', $postcode))->setTitle(str_replace('-', ' ', $postcode))->setWidth(100);
     $hnr = $translator->get('inputs.house-number');
     $this->houseNumber = Form::text($name . '-' . $hnr)->setTitle(str_replace('-', ' ', $hnr))->setPlaceholder(str_replace('-', ' ', $hnr))->setWidth(50);
     $ext = $translator->get('inputs.extension');
     $this->houseNumberExtension = Form::text($name . '-' . $ext)->setPlaceholder(str_replace('-', ' ', $ext))->setTitle(str_replace('-', ' ', $ext))->setWidth(150);
     $this->attachObserver($this->postcode);
     $this->attachObserver($this->houseNumber);
     $this->attachObserver($this->houseNumberExtension);
     // set the global placeholder style that will get copied down
     $this->addClass('address');
 }
Exemplo n.º 3
0
 /**
  * passing anything other than array should invalidate the validator and not set the Input array values
  * Upon rendering an exception should be thrown
  * @expectedException         Exception
  */
 public function testInvalidInputThrowsExceptionOnRender()
 {
     $input = Form::radio('test')->setValues('invalid')->setLabels('invalid');
     $input->render();
     $this->fail('rendering input element with invalid attributes should throw exception');
 }
Exemplo n.º 4
0
 /**
  * run() and isValid() are basically synonyms. They should behave mostly the same, but there are differences...!
  */
 public function testRunAndIsValid()
 {
     // create passing validation
     $_POST['test'] = 'foo';
     $input = Form::text('test');
     $this->validator->addValidation($input, 'alpha');
     $this->assertTrue($this->validator->run());
     $this->assertTrue($this->validator->isValid());
     // now add failing validation
     $this->validator->addValidation($input, 'min:5');
     // isValid will always return the result of the last run
     $this->assertTrue($this->validator->isValid());
     // each time you call run it will create a new WinkValidator and execute all validations
     $this->assertFalse($this->validator->run());
     $this->assertFalse($this->validator->isValid());
 }