Skip to content

Instantly share code, notes, and snippets.

@Doopin
Created January 18, 2015 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Doopin/f6fc72c5ac8fdc3243fc to your computer and use it in GitHub Desktop.
Save Doopin/f6fc72c5ac8fdc3243fc to your computer and use it in GitHub Desktop.
$inputFilter->add($factory->createInput(array(
array(
'name' => 'birthday',
'validators' => array(
array(
'name' => 'Zend\Validator\Date',
'break_chain_on_failure' => true,
)
),
'filters' => array(
array(
'name' => 'Callback',
'options' => array(
'callback' => function ($date) {
// Convert the date to database format, as allowed by the Validator\Date
if (!is_array($date) || empty($date['year']) || empty($date['month']) || empty($date['day'])) {
return null;
}
return $date['year'].'-'.$date['month'].'-'.$date['day'];
}
)
)
)
)
)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment