CI_Form_validation

class CI_Form_validation

set_rules($field[, $label = ''[, $rules = '']])
Parameters:
  • $field (string) – Field name
  • $label (string) – Field label
  • $rules (mixed) – Validation rules, as a string list separated by a pipe “|”, or as an array or rules
Returns:

CI_Form_validation instance (method chaining)

Return type:

CI_Form_validation

Permits you to set validation rules, as described in the tutorial sections above:

  • Setting Validation Rules
  • Saving Sets of Validation Rules to a Config File
run([$group = ''])
Parameters:
  • $group (string) – The name of the validation group to run
Returns:

TRUE on success, FALSE if validation failed

Return type:

bool

Runs the validation routines. Returns boolean TRUE on success and FALSE on failure. You can optionally pass the name of the validation group via the method, as described in: Saving Sets of Validation Rules to a Config File

set_message($lang[, $val = ''])
Parameters:
  • $lang (string) – The rule the message is for
  • $val (string) – The message
Returns:

CI_Form_validation instance (method chaining)

Return type:

CI_Form_validation

Permits you to set custom error messages. See Setting Error Messages

set_error_delimiters([$prefix = '

'[, $suffix = '

']])

Parameters:
  • $prefix (string) – Error message prefix
  • $suffix (string) – Error message suffix
Returns:

CI_Form_validation instance (method chaining)

Return type:

CI_Form_validation

Sets the default prefix and suffix for error messages.

set_data($data)
Parameters:
  • $data (array) – Array of data validate
Returns:

CI_Form_validation instance (method chaining)

Return type:

CI_Form_validation

Permits you to set an array for validation, instead of using the default $_POST array.

reset_validation()
Returns: CI_Form_validation instance (method chaining)
Return type: CI_Form_validation

Permits you to reset the validation when you validate more than one array. This method should be called before validating each new array.

error_array()
Returns: Array of error messages
Return type: array

Returns the error messages as an array.

error_string([$prefix = ''[, $suffix = '']])
Parameters:
  • $prefix (string) – Error message prefix
  • $suffix (string) – Error message suffix
Returns:

Error messages as a string

Return type:

string

Returns all error messages (as returned from error_array()) formatted as a string and separated by a newline character.

error($field[, $prefix = ''[, $suffix = '']])
Parameters:
  • $field (string) – Field name
  • $prefix (string) – Optional prefix
  • $suffix (string) – Optional suffix
Returns:

Error message string

Return type:

string

Returns the error message for a specific field, optionally adding a prefix and/or suffix to it (usually HTML tags).

has_rule($field)
Parameters:
  • $field (string) – Field name
Returns:

TRUE if the field has rules set, FALSE if not

Return type:

bool

Checks to see if there is a rule set for the specified field.

doc_CodeIgniter
2016-10-15 16:31:33
Comments
Leave a Comment

Please login to continue.