The documentation on this subject seems thin. I read the thread here on a similar problem, but something else is happening to me.
I am trying to create a database populated select list (pretty basic really).
After having no luck on this problem, I have reduced it to a basic example and still get the same error.
myform.xml
<fieldset name="essential" addfieldpath="/administrator/components/com_mycomp/models/fields">
...
<field name="myicon_image"
type="iconimagelist"
label="COM_MYCOMP_FIELD_MYFORM_ICON_IMAGE_LABEL"
description="COM_MYCOMP_FIELD_MYFORM_ICON_IMAGE_DESC"
id="myicon_image"
>
/administrator/components/com_mycomp/models/fields/iconimagelist.php (Straight out of the example modified the name)
<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
jimport('joomla.form.formfield');
class JFormFieldIconimagelist extends JFormField {
protected $type = 'iconimagelist';
// getLabel() left out
public function getInput() {
return '<select id="'.$this->id.'" name="'.$this->name.'">'.
'<option value="1" >New York</option>'.
'<option value="2" >Chicago</option>'.
'<option value="3" >San Francisco</option>'.
'</select>';
}
}
/administrator/components/com_mycomp/views/myform/tmpl/edit.php on line 7:
<?php foreach ($this->form->getFieldset('essential') as $field): ?>
The error comes back as
Call to a member function getFieldset() on a non-object in E:\_WEB\joomla\administrator\components\com_mycomp\views\myform\tmpl\edit.php on line 7
What I would really like to do is get the type to act as a list and just override the method to get the options, but I am having no luck with either approach.
WHEN I REMOVE THE FIELD FROM THE XML FILE, THE FORM WORKS, so I considering that to confirm the problem is only with the custom field type issue.
Any help would be greatly appreciated.