For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > June 2004 > preGenerateForm questions [FormBuilder]









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 preGenerateForm questions [FormBuilder]
Sarah Gray

2004-06-24, 1:22 am

Hi,

Can someone post an example of preGenerateForm() in action?
I've been getting errors when using it (it's in the DO). Think I've got
the syntax wrong.

function preGenerateForm(&$form){
$form->updateElementAttr('first_name', 'onchange="hello();"');
}

[I tried it in a bunch of other configurations, passing $do and $fg and
nothing -- but no luck. So I'm missing something].

erro: Call to undefined function: updateelementattr()

Anyway, I'd like to use preGenerateForms for a few things
(that I can do for the most part when *not* using it).

1. Attach special javascript events to specific elements (example
above). Works fine outside function as such:

$form->updateElementAttr('first_name', 'onchange="hello();"');

2. Create element groups so that I can apply styles later on. This I
can do fine outside of preGenerateForm -- but my group is created IN
ADDITION
to the elements in the form and appended to the end of the form. How
would I create that so
that it renders in the right order in the render -- ie, replaces the
original elements not duplicates them at the end?

This is my "working" but appending-not-replacing code:
$name[] = $form->getElement(first_name);
$name[] = $form->getElement(last_name);
$form->addGroup($name, 'nameGrp', 'Name Please');

3. Also -- if I wanted to pass along a piece of info with each element
that I could use when rendering, how would I do it?
Specifically I'd like to be able to have an element know if it was going
to be colspan 1, 2, etc. (And not have it dependent on the
element.type). Thoughts on passing xtra info with the elements that I
can parse in the renderer? Or should I just do this using style groups?

Thanks in advance,

s.
Sponsored Links







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

Copyright 2008 codecomments.com