QF(C) - contextsensitive forms

From: Date: Mon, 15 Dec 2003 20:06:30 +0000
Subject: QF(C) - contextsensitive forms
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9536@lists.php.net to get a copy of this message
Hi. In a QuickForm_Page instance I want to add a field to the Page if the user selects a specific element e.g. in a radiogroup. So I want to modify the form if the context changes. _Example:_ Are you married? [X] yes [] no For example you ask the user if he or she is married, if he/she selects "yes" you ask for the name of his/her partner (we need to add e.g. another textfield via addElement('text', ..) or so) This makes sense for the user, because I personally DO NOT hate anything MORE than fields in a form that dont apply to the data inserted before: 1. Question: Do you have a car? -> Answer: "No" 2. Question: Do you want to buy 3 tires at the prive of 2? -> Answer: "Eh......?... Ehm No.. Fuck you, silly website you!") _Idea_ 1) We put a javascript in both element above which submits the form. 2) The action on the server checks if there is anything to modify. If yes: we add or remove element#2 (field for name of the partner) and displays the updated page back to the user or just display the same as before. _Questions:_ 1) Would it be a good practice to overwrite the perform() method of a customized QFC Action? 2) If we submit the form via JavaScript (simply call document.formname.submit()) - would it be possible to tell QFC to call the right Action? How do I do this? 3) If this is possible, should not be any big prob to apply this to groups of elements, no? Yours, Matthias

« previous php.pear.general (#9536) next »