<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
* =======================================================
*
* CodeExtinguisher by jTaby
* CheckBox Plugin
* -------------------------
*
* YAML Configuration Options:
*
* +=============+================+================+
* | Required? | Name | Value |
* +=============+================+================+
* | Yes | class | Checkbox |
* | No | Value | Default Value |
* | No | Attributes | Default Atts |
* | No | Label | Label |
* +-------------+----------------+----------------+
*
* Example:
*
* field_name:
* class: CheckBox
* value: true
* label: This is a sample Label
*
*
* =======================================================
*/
class CheckBox extends codexForms
{
function CheckBox($name,$params) {
codexForms::initiate($name,$params);
}
function prepForDb ($value){
if(array_key_exists($this->name,$_POST))
return 1;
else{
return 0;
}
}
function in_arrayr($needle, $haystack) {
foreach ($haystack as $v) {
if ($needle == $v) return true;
elseif (is_array($v)) return $this->in_arrayr($needle, $v);
}
return false;
}
function prepForDisplay($value){
if(!empty($value))
return $this->label;
else
return '';
}
function getHTML()
{
$html = $this->prefix;
if($this->getMessage($this->name))
$html .= '<div class="failure">'.$this->getMessage($this->name).'</div>';
$html .= '
<label for="'.$this->element_name.'">
'.$this->label.'
</label>
<input type="checkbox" value="1"
';
if($this->value == true)
$html .= 'checked';
$html.='
name="'.$this->element_name.'" '.$this->getAttributes($this->attributes).'>
';
$html .= $this->suffix;
return $html;
}
}
?>
Comments (1)
apmyp said
at 7:13 am on Aug 16, 2009
I change return values in function prepForDb() to start working this function with BOOL (TINYINT(1)) format in MySQL
You don't have permission to comment on this page.