set_value()

set_value($field[, $default = ''[, $html_escape = TRUE]])

Parameters:
  • $field (string) – Field name
  • $default (string) – Default value
  • $html_escape (bool) – Whether to turn off HTML escaping of the value
Returns:

Field value

Return type:

string

Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function. The second (optional) parameter allows you to set a default value for the form. The third (optional) parameter allows you to turn off HTML escaping of the value, in case you need to use this function in combination with i.e. form_input() and avoid double-escaping.

Example:

<input type="text" name="quantity" value="<?php echo set_value('quantity', '0'); ?>" size="50" />

The above form will show “0” when loaded for the first time.

Note

If you’ve loaded the Form Validation Library and have set a validation rule for the field name in use with this helper, then it will forward the call to the Form Validation Library‘s own set_value() method. Otherwise, this function looks in $_POST for the field value.

doc_CodeIgniter
2016-10-15 16:32:39
Comments
Leave a Comment

Please login to continue.