Phpr_Form

This helper contains functions that can assist working with forms. Although it should be noted that using HTML is equally effective.

function form_open($attributes = array())

Returns string containing a FORM element opening tag with ACTION attribute referring current page. This function allows you to not bother about specifying ACTION attribute for each form on your website.

Parameters

  • $attributes - array. Optional associative array of attributes to set to the FORM tag.

Return value

Returns string.

Examples

The following code outputs a FORM tag with specified ID attribute.

<?= form_open(array('id'=>'my_form')) ?>
 
<!-- Produces -->
 
<form id="my_form" enctype="multipart/form-data" action="/page/url" method="post">

function form_close()

Returns string containing a FORM element closing tag. This function compliments the form_open tag for consistency.

Return value

Returns string.

Examples

The following code outputs a FORM closing tag.

<?= form_close() ?>
 
<!-- Produces -->
 
</form>

function form_label($text, $id, $attributes)

Returns a HTML label field.

Return value

Returns string.

function form_input($name, $value, $attributes)

Returns a HTML text input field.

Return value

Returns string.

function form_password($name, $value, $attributes)

Returns a HTML password input field.

Return value

Returns string.

function form_hidden($name, $value, $attributes)

Returns a HTML hidden text input field.

Return value

Returns string.

function form_file($name, $value, $attributes)

Returns a HTML file upload field.

Return value

Returns string.

function form_submit($name, $value, $attributes)

Returns a HTML submit element.

Return value

Returns string.

function form_reset($name, $value, $attributes)

Returns a HTML reset element.

Return value

Returns string.

function form_button($name, $text, $attributes)

Returns a HTML button element.

Return value

Returns string.

function form_dropdown($name, $options, $selected, $attributes, $empty_option)

Returns a HTML drop down element.

Return value

Returns string.

function form_radio($name, $value, $checked, $attributes)

Returns a HTML radio element.

Return value

Returns string.

function form_checkbox($name, $value, $checked, $attributes)

Returns a HTML checkbox element.

Return value

Returns string.

function form_widget()

TBA