【发布时间】:2018-01-05 12:04:50
【问题描述】:
我正在尝试在 ZF3 中将日期过滤器添加到我的表单中。所以在我的 FooForm 中我实现了 InputFilterProviderInterface 并在我的方法中得到了:
public function getInputFilterSpecification()
{
return [
'BarInput' => [
'validators' => [
[
'name' => StringLength::class,
'options' => [
'min' => 2,
'max' => 5,
],
],
],
'filters' => [
[
'name' => 'Zend\Filter\Date?'
]
所以对于过滤器,我不知道该放什么日期(我检查了文档,但我一无所知)。我的 dateInput 是一个字符串,我想输出一个 \DateTimeImmutable,以便将它正确保存在我的控制器中。
【问题讨论】:
-
在您的表单中使用
Zend\Element\Date或Zend\Element\DateSelect,它们具有正确的过滤器。 -
我当然使用 Zend\Element\Date 但 $form->getData()["date"] 是一个字符串,我的学说 orm 模块只接受我在实体中提到的日期对于这个特定的领域。
标签: date zend-framework zend-framework3 zend-inputfilter