Re: Pear HTML_QuickForm_Controller
| From: | Markus | Date: | Wed, 08 Oct 2003 00:27:52 +0000 |
| Subject: | Re: Pear HTML_QuickForm_Controller | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-8333@lists.php.net to get a copy of this message | ||
This migth work (in your action class):
function perform(&$page, $actionName) {
// do some stuff
$data =& $page->controller->container();
if ( isset($data['counter'] ) {
$data['counter']++;
} else {
$data['counter'] = 1;
}
$page->handle('display);
}
I think this will increase the counter with one every time you call
perform(). If you want to access the pointer from within your "page-class"
write:
$data =& $this->controller->container();
$counter = $data['counter'];
The $page->controller->container() refereces a $_SESSION variable (that
remains between subsequent calls - look in the PHP-manual). Don't forget to
add the "session_start();" line in your code (look at the QF_C examples).
No guarantee it will work but that is my tip. Tell me if I'm completely
wrong.
/Markus
"Daniel Kopp" <pear@daniu.de> wrote:
Hi!
Thanks for the help! Now it becomes a bit clearer. Unfortunately I am still
lacking some kind of breakthrough.
Now I decided to use a variable that should count the number of members. In
the beginning it should be set to 1 and then just increased by 1 through the
Actionhandle of 'AddMember'.
But ... How do I keep this variable alive throughout the session? Do I
really need to use a hidden field, setConstant and ask for the field each
time myself? Actually I would have wished that variables in the page-class
would just be kept throughout the session (is there a way to achieve that?).
And - where should I initialize it?
Thanks a lot for your worthy help - I spend so much time on this and I guess
you guys just know ...
Regards
Daniel
-----Original Message-----
From: Daniel Kopp [mailto:pear@daniu.de]
Sent: Monday, October 06, 2003 11:31 AM
To: pear-general@lists.php.net
Subject: [PEAR] Pear HTML_QuickForm_Controller
Hi!
I would like to have a Form were I can Add some fields by clicking a
(submit) Button. Like this:
Form to Enter family data ...
Button: "Add family member"
By clicking the button the form should be echoed again - with entry fields
for one more family member.
But ... How do I get back to the same form?
I had 2 ideas:
a rule:
$this->addElement('submit', 'add','Add User');
$this->addElement('submit',
$this->getButtonName('submit'),
'Send');
$this->addRule($this->getButtonName('submit'),
'Bitte Send eingeben', 'required', null 'client');
(to be honest - I don't really know what 'add' or
$this->getButtonName('submit') means or how it has to be but I tried a lot
so I just post it as I think this is not the problem even it might be wrong
here)
Unfortunately this does not work. It does not go back to the Form. It goes
to the handle of "Add User" which was never intended to exist.
The second solution would be to put it in the Form changing code in the
handle of "Add User" but then I don't know how to declare the form as
invalid and go back to it once more as the controller has finished
validation already ...
Any idea?
Thanks!
Daniel
PS.: this is my first post here - hope I did not make any major mistakes