The Form- and FieldRenderer allows you to create HTML forms to gather user input.
The FormRenderer let you specify the action, that should be triggered
on submitting the form.
A subclass of the Action class can be used, by overwriting the DoAction method, to handle the user input.
The user input can be accessed through the Contexts "Query" item, which itself contains a "fields" item storing all the fields and their values.
[[#wd DisplayAnythingRenderer { /AnythingInfo { "/MyForm {" " /Form {" " /Method "GET"" " /Action "MyFormAction"" " /Template {" " "My first field :[[ #wd Lookup MyFirstField ]]"" " "<p>My second field :[[ #wd Lookup MySecondField ]]"" " "[[ #wd Lookup MyButton ]]"" " ..." " }" " }" "}" } }]]Short description of the items :
[[#wd DisplayAnythingRenderer { /AnythingInfo { "/MyButton {" " /Button {" " /Name "MyButton"" " /Label {" " /String {" " /Default "Press Me"" " }" " }" " }" "}" " " "/MyFirstField {" " /Text {" " /Name "MyFirstField"" " /Value "Default"" " /Size 32" " }" "}" " " "/MySecondField {" " /CheckBox {" " /Name "MySecondField"" " /Checked "on"" " }" "}" } }]]For a close look to the FieldRenderer specification please refer to the appropriate documentation (or to the source code while the docu isn't available).
[[#wd DisplayAnythingRenderer { /AnythingInfo { "class MyFormAction : public Action" "{" " public:" " MyFormAction() {};" " virtual ~MyFormAction() {};" " virtual bool DoAction(String &action, Context &c);" "};" " " "RegisterAction(MyFormAction); // Add the Action to the registry" " " "// You only have to overwrite the DoAction method:" " " "bool MyFormAction::DoAction(String &name, Context &c)" "{" " Anything query = c.GetQuery();" " Anything fields = query["fields"];" " " " // Using the example above fields will look like this" " // /MyButton "Press Me"" " // /MyFirstField "Whatever has been enterd in this field"" " // /MySecondField "on" only if checked else it isn't there" " " " // code to handle the input" " StoreFieldsInFile();" " if (fields.IsDefined("MySecondField") {" " SendEMail();" " }" " ... etc" " action = "MyFormAction";" " return true;" "}" } }]]Remember that DoAction has to return the name of an "? action ?", that is defined in /Map and will be used to find the next page.
[[#wd DisplayAnythingRenderer { /AnythingInfo { "/Actions {" " /MyFormAction {" " "MyForm"" " }" " ... other Actions" "}" } }]]
HTMLTemplateRenderer, FormRenderer, FieldRenderer, Action