Last active
September 24, 2018 18:48
-
-
Save marcosrocha85/aee2bef5b3cb0d923b056f1d290bfc35 to your computer and use it in GitHub Desktop.
CodeIgniter form_pretty_checkbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Pretty Checkbox Field for CodeIgniter and pretty-checkbox-vue from @hamed-ehtesham | |
* | |
* @access public | |
* @param mixed | |
* @param string | |
* @param bool | |
* @param string | |
* @return string | |
*/ | |
if (!function_exists('form_pretty_checkbox')) | |
{ | |
function form_pretty_checkbox($data = '', $value = '', $checked = FALSE, $extra = '') | |
{ | |
$defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); | |
if (is_array($data) AND array_key_exists('checked', $data)) | |
{ | |
$checked = $data['checked']; | |
if ($checked == FALSE) | |
{ | |
unset($data['checked']); | |
} | |
else | |
{ | |
$data['checked'] = 'checked'; | |
} | |
} | |
if ($checked == TRUE) | |
{ | |
$defaults['checked'] = 'checked'; | |
} | |
else | |
{ | |
unset($defaults['checked']); | |
} | |
return "<p-check "._parse_form_attributes($data, $defaults).">".$extra."</p-check>"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment