I had the solution but it was hidden behind another error
in my BaseForm.php
// Inintialise date field
protected function setFieldDate($table, $field, $mandatory = false)
{
$validate = array();
$dateField = new Date($field);
$dateField->setLabel($this->_($table . ucfirst($field)));
$dateField->setFilters(array('striptags', 'string'));
$dateField->setAttribute('placeholder', $this->_('help_' . $table . ucfirst($field)));
if ($mandatory)
{
$dateField->setAttribute('required', 'true');
$dateField->setAttribute('aria-required', 'true');
array_push($validate, new PresenceOf(array(
'message' => $this->_($table . ucfirst($field) . 'Required')
)));
}
if (sizeof($validate) > 0) $dateField->addValidators($validate);
return $dateField;
}
in my personForm.php
$birthdate = $this->setFieldDate("person", "birthdate", false);
$this->add($birthdate);
in my view
<div class='form-group'>
<div class="col-md-3 offset-3 form-label">
{{ form.label('birthdate') }}
</div>
<div class="col-md-2">
{{ form.render('birthdate', ["class": "form-control"]) }}
{{ form.messages('birthdate') }}
</div>
</div>
Default setters and getters in Model and it work