Re: [fw-general] Zend\Form\Element\DateTime problem with data format

2013-04-28 Thread David Muir
My guess is that it's because your value is outside the min/max range 
you've specified.
'value' would be today, 'min' would be 30 months ago, and 'max' is 18 
months ago.
You're subtracting 30 months from $date, then adding 1 year back to it 
again. You'll want to add 42 months back to it, or clone your date 
object for each date calculation.


Cheers,
David


On 17/10/12 22:56, miszyman wrote:

Hi,

I'm currently migrating from ZF1 to ZF2, and I have some trouble in creating
forms, one of them is I cannot properly set the date format for the DateTime
element I am trying to do sth like this (i've changed it a few times but its
just to get the idea)

$date = new \DateTime();
$date_formated = $date->format('d/m/Y H:i');


$this->add ( array (
'name' => 'registration_starts',
'type' => 'Zend\Form\Element\DateTime',
'options' => array (
'format'=>'d/m/Y H:i',
'label' => 'Registration start 
Date/Time',

),
'attributes' => array (
'value'=> $date_formated,
'class'=>'datetime picker',
'min' => $date->sub(new 
\DateInterval('PT30M'))->format('d/m/Y H:i'),
'max' => $date->add(new 
\DateInterval('P1Y'))->format('d/m/Y H:i'),
'step' => '1',
)
)
);
$this->get('trn_registration_starts')->setFormat('d/m/Y H:i');

and with such element I get error "Invalid date param given" from the
Zend/Validator/DateStep.php:234, how should it be done?

In future I'd also like to set the date format from the users locale;>




--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Form-Element-DateTime-problem-with-data-format-tp4657657.html
Sent from the Zend Framework mailing list archive at Nabble.com.




--
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




[fw-general] Zend\Form\Element\DateTime problem with data format

2012-10-17 Thread miszyman
Hi,

I'm currently migrating from ZF1 to ZF2, and I have some trouble in creating
forms, one of them is I cannot properly set the date format for the DateTime
element I am trying to do sth like this (i've changed it a few times but its
just to get the idea)

$date = new \DateTime();
$date_formated = $date->format('d/m/Y H:i');


$this->add ( array (
'name' => 'registration_starts',
'type' => 'Zend\Form\Element\DateTime',
'options' => array (
'format'=>'d/m/Y H:i',
'label' => 'Registration start 
Date/Time',

),
'attributes' => array (
'value'=> $date_formated,
'class'=>'datetime picker',
'min' => $date->sub(new 
\DateInterval('PT30M'))->format('d/m/Y H:i'),
'max' => $date->add(new 
\DateInterval('P1Y'))->format('d/m/Y H:i'),
'step' => '1',
)
)
);
$this->get('trn_registration_starts')->setFormat('d/m/Y H:i');

and with such element I get error "Invalid date param given" from the
Zend/Validator/DateStep.php:234, how should it be done?

In future I'd also like to set the date format from the users locale;>




--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Form-Element-DateTime-problem-with-data-format-tp4657657.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com