00566: Allow value defaults for input form controls

Summary: Allow value defaults for input form controls
Created: 2005-10-21 11:05
Status: Closed - exists since 2.2 beta
Category: CoreCandidate
From: Pm
Assigned:
Priority: 4
Version: 2.0.11
OS:

Description: This entry simply notes that Pm is planning to add an $InputValues variable that sets the default values to be used for various controls using the Forms markup.

In particular, setting

    $InputValues['xyz'] = 'alpha bravo';

will mean that any input form control with the name 'xyz' will use 'alpha bravo' as its default value (in absence of any value= option).

A script can easily do

   $InputValues = array_merge((array)$InputValues, $_REQUEST)

to say "default all form controls to the values that came from the last request". Similarly, a script could load default values for form controls from a database or other source.


As long as you're adding this capability to forms.php, how about adding a parameter to the (:input form:) tag that will set the contents of the form as shown above?

For example, (:input form values=get:) would fill the form only with $_GET values, values=post with $_POST values, values=cookie with $_COOKIE values, and values=request with $_REQUEST (which is all three). Just a thought.

Ben Stallings August 24, 2006, at 05:19 PM


I agree that some way to get values from $_GET, $_POST, etc should be part of core (:input form ...:). I think values submitted should automatically become available somehow in the page itself (via PV or PTV or something).

Until it's available in core, check out Cookbook.ProcessForm.