form_button()

form_button([$data = ''[, $content = ''[, $extra = '']]])

Parameters:
  • $data (string) – Button name
  • $content (string) – Button label
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
Returns:

An HTML button tag

Return type:

string

Lets you generate a standard button element. You can minimally pass the button name and content in the first and second parameter:

echo form_button('name','content');
// Would produce: <button name="name" type="button">Content</button>

Or you can pass an associative array containing any data you wish your form to contain:

$data = array(
        'name'          => 'button',
        'id'            => 'button',
        'value'         => 'true',
        'type'          => 'reset',
        'content'       => 'Reset'
);

echo form_button($data);
// Would produce: <button name="button" id="button" value="true" type="reset">Reset</button>

If you would like your form to contain some additional data, like JavaScript, you can pass it as a string in the third parameter:

$js = 'onClick="some_function()"';
echo form_button('mybutton', 'Click Me', $js);
doc_CodeIgniter
2016-10-15 16:32:18
Comments
Leave a Comment

Please login to continue.