Welcome Guest, Not a member yet? Register   Sign In
Customising a helper (not taken into account) form_helper.php
#5

[eluser]Monarobase[/eluser]
I've got some news, I think I've solved the problem...

I noticed that the form_validation library also contained a function set_radio so I created a MY_Form_valadation.php in my application library folder.

I then put this in my file :

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Form_validation extends CI_Form_validation  {
    
    function set_radio($field = '', $value = '', $default = FALSE)
    {
        if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
        {
            if (($default === TRUE OR $default == $value) AND count($this->_field_data) === 0)
            {
                return ' checked="checked"';
            }
            return '';
        }
    
        $field = $this->_field_data[$field]['postdata'];
        
        if (is_array($field))
        {
            if ( ! in_array($value, $field))
            {
                return '';
            }
        }
        else
        {
            if (($field == '' OR $value == '') OR ($field != $value))
            {
                return '';
            }
        }
            
        return ' checked="checked"';
    }
    
}
// END Form Validation Class

/* End of file Form_validation.php */

And it seems to work ... !

Now my final question is, is there no better way to achieve the same result ?


Messages In This Thread
Customising a helper (not taken into account) form_helper.php - by El Forum - 01-16-2010, 10:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB