I 've created a custom form field type
class JFormFieldCategories extends JFormFieldList
{
protected $type = 'categories';
public function getOptions()
{
$db = JFactory::getDBO();
$categories=array();
$sql = "select * from #__table";
$db->setQuery( $sql );
$results = $db->loadObjectList();
if(count($results)>0)
{
foreach($results as $resc){
$options[$resc->id] = $resc->description;
}
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
I have added the field to the form
<field name="discount_on_categories" type="categories" multiple="true" size="40" />
This is a multiple select value. What shall i do to save the selected values to the database and show them when i edit the item?
var_dump()
to see if any values are retrieved?