|Getting StartedHelpful ResourcesAsk questions on the Help ForumRead the User GuideBrowse the Reference DocumentationSubscribe to the Helix Mailing ListLearning Helix|
Using forms in your web application is very simple with the Helix form class and the form input classes You can create any of the standard HTML form input elements using the Helix form classes like:
There are also more useful custom form controls that are made from a combination of the simple form controls like:
Displaying Forms In Helix
Displaying a form on a page is handled by the form classes mentioned above. Just open the form tag, add some form inputs, then close the form tag.
See the code below for an example of how to use a form on a page:
The code above creates a form with id login-form, two text boxes for a username and password, and a button to submit the form and call a function in the codebehind for that page. The second parameter to the input::open() method that defines the username field tells Helix what options to use as the value to that input. The alt() method takes 1 or more parameters and returns the value of the first non-null parameter. The reqval() method takes an array key as a parameter and returns a value from the PHP $_REQUEST array if the key exists. Using these methods together has the effect of showing the last posted value in the text box, or nothing if there is no posted value. The third parameter passed to the input::open() method tells Helix what to use for the type attribute.
The third parameter to the new button() constructor is a name of a function in the codebehind file for that page. The button object will insert a hidden input into the form with an input name of f and value of the codebehind function name. When this form is submitted, the form input values will be passed to the server and the codebehind function named authenticate_user will be called.