[eluser]James Gifford[/eluser]
I modified the form_helper.php and Form_validation.php files to add the set_label function. Its pretty much the same as the set_value function.
form_helper:
Code:
/**
* Set Label
*
* If Form Validation is active it retrieves the info from the validation class
*
* @access public
* @param string
* @return mixed
*/
if ( ! function_exists('set_label'))
{
function set_label($field = '', $default = '')
{
if (FALSE === ($OBJ =& _get_validation_object()))
{
return '';
}
return form_prep($OBJ->set_label($field, $default));
}
}
form_validation:
Code:
/**
* Get the value for a form label
*
* Permits you to populate a form label with the value set in form_validation
* or, if that value doesn't exist, with the default
*
* @access public
* @param string the field name
* @param string
* @return void
*/
function set_label($field = '', $default = '')
{
if ( ! isset($this->_field_data[$field]))
{
return $default;
}
return $this->_translate_fieldname($this->_field_data[$field]['label']);
}
EDIT: I should mention that I've also modified Form_validation.php by removing the first few lines of the set_rules() method which ignores the rules of there is no post data.
Of course, if there's an easier way to get the label value that would be even better.