/** * render the date input element * @return string */ public function render() { // check result of validity checks of parameters passed to this Input element $this->checkValidity(); // we will show/hide the container div for the text field and the image and not the text field and the image themselves $hidden = $this->getHidden() === true ? ' style="display:none;"' : ''; $this->setHidden(false); // the text field must have the selected values $this->text->setValue($this->value); $this->text->setSelected($this->selected); $this->text->setRenderWithLabel($this->renderWithLabel); $output = $this->renderLabel(array('class' => 'date-element')) . '<div id="' . $this->id . '-container" class="inputs-container date-element"' . $hidden . $this->renderStyle() . '>' . $this->text->render() . '</div>' . PHP_EOL; if (empty($this->disabled)) { $output .= $this->getJS() . PHP_EOL; } $output .= $this->renderInvalidations(); return $output; }
/** * test renderValidationErrors() */ public function testRenderValidationErrors() { $input = new TextInput('foo', 'value'); $input->setValue(array('one', 'two')); // setValue doesn't accept array $input->addClass('$@#$%^&'); // no special chars allowed in class name $errors = $input->renderValidationErrors('my custom message'); $this->assertContains('div class="error"', $errors); $this->assertContains('my custom message', $errors); $input = new TextInput('foo', 'value'); $errors = $input->renderValidationErrors(); $this->assertEmpty($errors); }