 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
rob101
Joined: 18 Feb 2008 Posts: 2
|
Posted: Mon Feb 18, 2008 5:09 pm Post subject: Confused about Quickform's groups |
|
|
I've just started using quickform, I really like it. ALl the problems I've come up against have been solved by some serious googling, except one...
Once defined, can a group not be used more than once?
I would have expected this to create two instances of a group, but it doesn't seem to work like that.
Is there any way a group array be reused?
Many thanks, Rob
| Code: | <?php
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm('form', 'get');
$person[] = $form->createElement('text', 'firstname');
$person[] = $form->createElement('text', 'secondname');
$form->addGroup($person, 'person1', 'First Person', ' ');
$form->addGroup($person, 'person2', 'Second Person', ' ');
$form->addElement('submit', 'btnSubmit', 'Submit');
if ($form->validate()) {$form->freeze();$form->display();}
else {$form->display();} |
|
|
| Back to top |
|
 |
orixilus
Joined: 04 Jan 2008 Posts: 8
|
Posted: Thu Feb 21, 2008 8:02 pm Post subject: |
|
|
Rob,
You're using the same instance of "firstname" and "secondname" on both groups - i think that's the problem.
you'll need to create two sets of fields, one for each group.
| Code: |
$person1[] = $form->createElement('text', 'firstname1');
$person1[] = $form->createElement('text', 'secondname1');
$person2[] = $form->createElement('text', 'firstname2');
$person2[] = $form->createElement('text', 'secondname2');
$form->addGroup($person1, 'person1', 'First Person', ' ');
$form->addGroup($person2, 'person2', 'Second Person', ' ');
|
|
|
| Back to top |
|
 |
rob101
Joined: 18 Feb 2008 Posts: 2
|
Posted: Fri Feb 22, 2008 7:00 pm Post subject: |
|
|
Thanks for letting me know.
My actual group was unfortunately a lot more complicated than two fields, and needs to be replicated many more times; so I was just trying to reuse code rather than manually replicating it!
Thanks anyway, R |
|
| Back to top |
|
 |
Mittineague

Joined: 26 May 2007 Posts: 42
|
Posted: Sat Feb 23, 2008 12:03 am Post subject: manually replicating code |
|
|
| You may not need to manually replicate the code. If the groups are similar you could create them dynamically in a loop. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|