I would like to add a placeholder to my date input to show visitors using firefox which format the date must have.
Using Zend Framework 2, I want to be able to generate an input equivalent to :
<input type="date" placeholder="yyyy-mm-dd">
inside my Form class.
Here is the Form class I have right now :
<?php
namespace MyModule\Form;
use Zend\Form\Form;
class MyModuleForm extends Form {
public function __construct($name = null) {
parent::__construct('myModule');
$this->add(array(
'name' => 'TheDate',
'type' => 'date',
'attributes' => array(
'placeholder' => 'yyyy-mm-dd',
'class' => 'form-control',
)
));
}
}
?>
But Zend seems to skip the "placeholder" attribute and generates only :
<input class="form-control" type="date" value="" name="TheDate">
In the worst case scenario, I know I can also definse the "value" attribute instead (though I would like not to, just in case the user doesn't pay attention and doesn't change it), or add the placeholder manually using javascript. But is there a more elegant way to do what I want to achieve through the Form class of Zend ?