trOnGAtE

The Form Helper
The Form Helper is a class that has been created to assist with rapid creation of online forms. The following features are available from the Form Helper:
Form Open
Purpose: Generates form open tag for a form that is to be used for HTTP POST requests.
Arguments: Accepts up to three arguments:
- 1st Argument: $location - a string representing the location that you would like your form to be posted to.
- 2nd Argument (optional): $attributes - an array containing key value pairs that can be added to the form opening tags.
- 3rd Argument (optional): $additional_code - a string that can be added onto the end of the form tag.
For Example:
Let's assume that you are building a form for the following website URL:
http://www.your-site.com/members
Let's also assume that you wanted to build a form that is to initiate a POST request that is to be sent to:
http://www.your-site.com/members/submit
To generate form opening tags, we could use the following code inside of a view file:
<?php echo form_open('members/submit'); ?>
The above code will generate the following HTML:
<form action="http://www.your-site.com/members/submit" method="post">
PLEASE NOTE: The result above is made with the assumption that the BASE_URL is set to http://www.your-site.com/
Form Close
Purpose: Generate a simple form close tag.
Example:
<?php echo form_close(); ?>
The above code will generate the following HTML:
</form>
Form Input Helpers
The Trongate framework also comes with a rich assortment of form field helpers. The table below references all of the form field helpers that are available for use:
Method | Arguments |
---|---|
form_label Purpose: Output a form label. |
|
form_input Purpose: Output form input (text) field. |
|
form_email Purpose: Output form input (email) field. |
|
form_password Purpose: Output form input (password) field. |
|
form_hidden Purpose: Output hidden form input field. |
|
form_textarea Purpose: Output form textarea field. |
|
form_dropdown Purpose: Output form select menu. |
|
form_checkbox Purpose: Output form checkbox. |
|
form_radio Purpose: Output form radio button. |
|
Form Buttons
The Form Helper also offers the following two helpers for generating form buttons:
Form Open Upload
Purpose: Creates a form opening tag for uploading files. It accepts the same arguments as the Form Open helper, as explained above.
Example:
<?php echo form_open_upload('members/submit_upload_picture'); ?>
The above code will generate the following HTML:
<form action="http://www.website.com/members/submit" method="post" enctype="multipart/form-data">
PLEASE NOTE: The result above is made with the assumption that the BASE_URL is set to http://www.website.com/
HELP & SUPPORT
If you have a question or a comment relating to anything you've see here, please goto the Help Bar.