Welcome Guest, Not a member yet? Register   Sign In
Displaying labels in HTML from $config
#3

[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.


Messages In This Thread
Displaying labels in HTML from $config - by El Forum - 10-30-2008, 09:20 PM
Displaying labels in HTML from $config - by El Forum - 11-06-2008, 03:08 PM
Displaying labels in HTML from $config - by El Forum - 11-06-2008, 03:23 PM
Displaying labels in HTML from $config - by El Forum - 11-10-2008, 04:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB