[eluser]abmcr[/eluser]
I have try to use the buildin function set_checkbox() for managing the post data and the prepopulate data... and i have not success...
I have write my set_checkbox function , extending the core librarie
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class MY_Form_validation extends CI_Form_validation
{
function MY_Form_validation()
{
parent::CI_Form_validation();
}
// --------------------------------------------------------------------
/**
* Set Checkbox
*
* Enables checkboxes to be set to the value the user
* selected in the event of an error, or to value from DB
*
* @access public
* @param string
* @param string
* @return string
*/
function set_checkbox($field = '', $value = '', $default = FALSE)
{
if (isset($_POST[$field])) {
return ' checked="checked"';
}
if (count($_POST)==0){
if($value==$default) {
return ' checked="checked"';
}else{
return '';
}
}
}
}
?>
In the view file
simple type this
Code:
<input type="checkbox" name="attivo" value="y" <?php echo set_checkbox('attivo', 'y',$row->attivo); ?> />
where $row->attivo if the value from db.....
Any suggestion for a use of core function?