this documentation should be used starting with product versions bigger then Auction Factory 1.6.9 and Ads Factory 1.5.4
class FieldType_inputBox extends FactoryFieldTypes{
var $type_name = "TextBox";
var $class_name = "inputBox";
var $has_options = 0;
var $sql_type = "varchar";
var $length = 200;
var $_attributes = null;
var $_options = null;
function display($name, $id, $css_attributes="", $css_class="", $javascript_attributes="" ){
$attributes = $this->prepareAttributesString();
$css_class = $this->prepareClassName($css_class);
return "<input type=\"text\" name=\"$name\" id=\"$id\" $attributes class=\"$css_class\"
style=\"$css_attributes\" $javascript_attributes value=\"".htmlentities($this->value)."\" />";
}
function display_search($name, $id, $css_attributes="", $css_class="", $javascript_attributes="" ){
return $this->display($name, $id, $css_attributes, $css_class, $javascript_attributes );
}
}
You can add your check class as the input posted above. Customize the display and show search methods adding the name of the control to the fields.config.ini in the field_list= param .
You should have a class like:
class FieldType_checkBox extends FactoryFieldTypes
and add in the field_list "checkBox"
COLLECT MULTIPLE OPTIONS:
"overwrite the getVar method"
class FieldType_checkbox must have it's definition of the FactoryFieldTypes getVar method so the multiple options are collected all from $_POST.
"add the [] to the controller html field name "
A multiple optioned html control must have the name "name[]" instead of "name" in it's html output like bellow:
<input type="checkbox" name="mynice_name[]" value="value1" />
<input type="checkbox" name="mynice_name[]" value="value2" />
Note! A checkbox group is a multi option controlled by it's behavior - you can select more than one checkbox and all checkboxes refer to the same property.
PLUGIN EXAMPLE FOR A CHECKBOX FIELD:
class FieldType_checkbox extends FactoryFieldTypes{
var $type_name = "CheckBox";
var $class_name = "checkBox";
var $has_options = 1;
var $sql_type = "varchar";
var $length = 200;
var $_attributes = null;
var $_options = null;
function display($name, $id, $css_attributes="", $css_class="", $javascript_attributes="" ){
$this->value = explode(",", $this->value);
$css_class = $this->prepareClassName($css_class);
$ret = "";
if(count($this->_options))
foreach($this->_options as $k => $option){
$selected = " ";
if( in_array($option->option_name,$this->value) )
$selected = " checked=\"checked\" ";
$ret.= "<input type=\"checkbox\" name=\"{$name}[]\" id=\"$id\" $selected value=\"".htmlentities($option->option_name)."\" > ".$option->option_name;
}
return $ret;
}
function getVar($name){
return implode(",",FactoryLayer::getRequest( $_REQUEST, $name ));
}
function getValue(){
return $this->value;
}
}