Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
Test /
InputDefaults
|
(:input default rating medium:) (:input radio rating none:) None (:input radio rating low:) Low (:input radio rating medium:) Medium (:input radio rating high:) High (:input radio rating extreme:) Extreme |
None Low Medium High Extreme |
Of course, (:input default ...:) works for any control, not just radio buttons:
(:input default color red:) (:input checkbox color white:) White (:input checkbox color green:) Green (:input checkbox color red:) Red (:input checkbox color blue:) Blue |
White Green Red Blue |
From within a script, the $InputValues array can also be used to set default values for form controls. These can come from any source -- including from a previous POST or GET operation. For example, this page has the following local customization enabled in local/Test.InputDefaults.php:
foreach ($_GET as $k=>$v)
$InputValues[$k] = htmlspecialchars($v);
As a result, any values from a previous form submission are used to set the defaults of the controls. Try setting the form below, press "Go", and notice how the form controls retain their values even after submit is pressed:
(:input form method=get:) Colors: (:input checkbox red 1:) Red (:input checkbox blue 1:) Blue (:input checkbox green 1:) Green Extras: (:input radio extras yes:) Yes (:input radio extras no:) No Name: (:input text name:) Year: (:input select year 2006:) (:input select year 2007:) (:input select year 2008:) (:input submit:) (:input end:) |
The (:input default ...:) directive above is simply an easy way to use markup to set entries in $InputValues. However, the (:input default:) directive won't replace any value that already exists (thus a form submission will take priority over the markup defaults).
(:input defaults source=Cookbook.Fox:) (:input textarea name=$:Summary cols=50 rows=5 :) |
|
0: 00.00 00.00 config start 1: 00.00 00.00 config end 2: 00.11 00.07 MarkupToHTML begin 3: 00.12 00.07 MarkupToHTML begin 4: 00.14 00.09 MarkupToHTML end 5: 00.14 00.09 MarkupToHTML begin 6: 00.14 00.10 MarkupToHTML end 7: 00.14 00.10 MarkupToHTML begin 8: 00.17 00.13 MarkupToHTML end 9: 00.17 00.13 MarkupToHTML begin 10: 00.19 00.14 MarkupToHTML end 11: 00.28 00.24 MarkupToHTML end 12: 00.30 00.25 MarkupToHTML begin 13: 00.33 00.28 ReadApprovedUrls SiteAdmin.ApprovedUrls begin 14: 00.34 00.29 ReadApprovedUrls SiteAdmin.ApprovedUrls end 15: 00.36 00.31 MarkupToHTML end 16: 00.36 00.31 MarkupToHTML begin 17: 00.37 00.32 MarkupToHTML end 18: 00.38 00.34 now