Porting of HTML_QuickForm_Controller

Page should aggregate Form

Common complaint is that in QuickForm 3.x / QuickForm_Controller 1.x HTML_QuickForm_Page extended HTML_QuickForm and therefore it was impossible to use customized subclass of HTML_QuickForm with Controller. For example, in HTML_QuickForm_DHTMLRulesTableless package two classes had to be implemented: HTML_QuickForm_DHTMLRulesTableless extending HTML_QuickForm and HTML_QuickForm_PageDHTMLRulesTableless extending HTML_QuickForm_Page.

Thus Page in QF2 should accept an instance of HTML_QuickForm2.

Setting the 'action'

Allow setting the 'action' attribute for all forms in Controller. Or at least allow iterating over forms to set it manually.

buildFormOnce()

Implement a method calling buildForm() only once, to prevent the need of setting _formBuilt in there. Nuff said.

Session DataSource

QuickForm_Controller used a hackish technique of injecting form values stored in session into the _submitValues property of HTML_QuickForm_Page. With DataSources in QF2 hacks are no longer necessary. Need to check whether we should implement DataSource_Submit here. We should: in the other case stuff like multiselects and checkboxes will behave wrong (see bug #5615).

DataSource for defaults

We still need to store default values in session, this will require serializing the whole datasource in QuickForm2, especially if said datasource will need some parameters for its work (e.g. when we use unique Controller names).

Unique Controller name?

Controller stores its values in session keyed with its name. So to run two Controllers in parallel they should have different names. This is doable now, but you'll have to pass that name manually, e.g. Jump action won't use it.

Maybe we should add an option of generating an unique (part of) name and pass it with Jump action. No sense in autogenerating, but Controller should be able to get its name from request variables. That'll allow running several identical Controllers in parallel.

Something like the following will be needed

// don't provide name here, this will make Controller get one from request vars
$controller = new HTML_QuickForm2_Controller();
if (!$controller->getName()) {
   // no name in request yet, initialize Controller
   $controller->setName($someName);
   $controller->addDatasource($defaultsDatasource);
}

N.B. a destroyContainer() method will be useful here, since much more junk may end up in session if we use more controller names.

setDefaultAction()

Need to research a crossbrowser way to set default action when user submits form with Enter key rather than by clicking on one of the named submits.

Actually, it might be better to rely on an hidden field than on the submit element.

Quoting from email: The problem is we are relying on hidden field right now and it doesn't work. Browsers just send the “value” attribute of the first (for the given value of “first”?) submit button of the form when pressing “Enter”. So the problem is making the “default” button also “first”.

Here are some relevant links:

An interesting idea is to have an <input type=“image” /> which is just an 1×1 transparent GIF

 
controller.txt · Last modified: 2010/07/09 15:59 by golgote