From 707d0e0f1e0ea922fbe38d8b43f1fb4e2ea001e5 Mon Sep 17 00:00:00 2001
From: Derek Allard Similar to the other form functions in this helper, you can also pass an array of attributes to the function:
$data = array(
- 'name' => 'newsletter',
- 'id' => 'newsletter',
- 'value' => 'accept',
- 'checked' => TRUE,
- 'style' => 'margin:10px',
- );
+ 'name' => 'newsletter',
+ 'id' => 'newsletter',
+ 'value' => 'accept',
+ 'checked' => TRUE,
+ 'style' => 'margin:10px',
+ );
echo form_checkbox($data);
@@ -331,8 +331,8 @@ fourth parameter:
Similar to other functions, you can submit an associative array in the third parameter if you prefer to set additional attributes.
$attributes = array(
- 'class' => 'mycustomclass',
- 'style' => 'color: #000;',
+ 'class' => 'mycustomclass',
+ 'style' => 'color: #000;',
);
echo form_label('What is your Name', 'username', $attributes);
@@ -342,6 +342,39 @@ fourth parameter:
Lets you generate a standard reset button. Use is identical to form_submit().
+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="submit">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);
+
+
+
Produces a closing </form> tag. The only advantage to using this function is it permits you to pass data to it -- cgit v1.2.3-24-g4f1b