/** * 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'); }
/** * 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()); }