PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Confused about Quickform's groups

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML
View previous topic :: View next topic  
Author Message
rob101



Joined: 18 Feb 2008
Posts: 2

PostPosted: Mon Feb 18, 2008 5:09 pm    Post subject: Confused about Quickform's groups Reply with quote

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', '&nbsp;');
   $form->addGroup($person, 'person2', 'Second Person', '&nbsp;');
   
    $form->addElement('submit', 'btnSubmit', 'Submit');
   
   if ($form->validate()) {$form->freeze();$form->display();}
    else {$form->display();}
Back to top
View user's profile Send private message
orixilus



Joined: 04 Jan 2008
Posts: 8

PostPosted: Thu Feb 21, 2008 8:02 pm    Post subject: Reply with quote

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', '&nbsp;');
$form->addGroup($person2, 'person2', 'Second Person', '&nbsp;');
Back to top
View user's profile Send private message
rob101



Joined: 18 Feb 2008
Posts: 2

PostPosted: Fri Feb 22, 2008 7:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mittineague



Joined: 26 May 2007
Posts: 43

PostPosted: Sat Feb 23, 2008 12:03 am    Post subject: manually replicating code Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software