For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > April 2006 > formBuilder:converting an auto generated date field in a hidden field









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author formBuilder:converting an auto generated date field in a hidden field
Didier Galland

2006-04-22, 7:00 pm

Hello,

I have problems converting auto generated date fields (field of type
date in db) in hidden fields.
$el['mdate']=& HTML_QuickForm::createElement('hidden','
mdate'); in
preGenerateForm doesn't work well (*Warning*: htmlspecialchars() expects
parameter 1 to be string, array given in
*C:\wamp\php\PEAR\HTML\Common.php* on line *150). I suppose this is
because "mdate" isn't really a field but is an array mdate[d], mdate[m]...

$form->removeElement('mdate');
$form->addElement('hidden','mdate');
$form->setConstants(array('mdate'=>date('Y-m-d'));
in *preGenerateForm() doesn't work either because a string
('2006-04-22') is passed to the array2date callback.

Well, while writing this mail, I've tried an other solution ! I Finally
succeded with this (in preGenerateForm()):

$form->removeElement('mdate');
$form->addElement('hidden','mdate[Y]');
$form->addElement('hidden','mdate[m]');
$form->addElement('hidden','mdate[d]');
$form->setConstants(array('mdate[Y]'=>date('Y'),'mdate[m]'=>date('m'),'mdate[d]'=>date('d')));

It works, but isn't there a more simple way to do this ? It seems to be
very heavy for just a little change...

Regards,

Didier








________________________________________
___________________________________
Faites de Yahoo! votre page d'accueil sur le web pour retrouver directement vos services préférés : vérifiez vos nouveaux mails, lancez vos recherches et suivez l'actualité en temps réel.
Rendez-vous sur http://fr.yahoo.com/set
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com