Skip to content

Instantly share code, notes, and snippets.

@juliangorge
Created March 17, 2015 17:41
Show Gist options
  • Save juliangorge/27043ff1dcca7657057d to your computer and use it in GitHub Desktop.
Save juliangorge/27043ff1dcca7657057d to your computer and use it in GitHub Desktop.
Convert a datepicker string to database date format.
<script> $(function() { $('#date').datepicker({dateFormat: 'dd-mm-yy'}); }); </script>
<?php echo $this->formRow($form->get('date')); ?>
<?php
class MyFormFieldset extends Fieldset implements InputFilterProviderInterface
{
public function __construct() //I am using DoctrineModule 2.. I remove it configuration.
{
/* ... */
$this->add(array(
'name' => 'date',
'type' => 'Zend\Form\Element\Text',
'attributes' => array(
'id' => 'date',
'placeholder' => '31-01-2016',
),
));
}
public function getInputFilterSpecification()
{
'date' => array(
'required' => true,
'validators' => array(
array(
'name' => 'Zend\Validator\Date',
'options' => array(
'min' => date('d-m-Y'),
),
),
),
'filters' => array(
array(
'name' => 'Zend\Filter\DateTimeFormatter',
'options' => array(
'format' => 'Y-m-d'
),
),
),
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment