Undefined property on custom form field

63 views
Skip to first unread message

Neo314

unread,
May 20, 2013, 3:05:26 AM5/20/13
to joomla-de...@googlegroups.com
Can anyone help me with this error?

I must have some difference in installs or server settings of Joomla 2.5.11, because I see this error on one install and not the other, but I am really looking to resolve it rather than figure out why it shows up on one of the installs.

Notice: Undefined property: JFormFieldStatefk::$class in /var/www/html/joomla.test/libraries/joomla/form/field.php on line 250

It relates to the custom field statefk which is a state value I'm using to preserve a foreign key. The state value was getting lost sometimes, and so I was outputting it in a read only field.

The xml code of the field is:

<field name="parentGroup_id"
type="statefk"
label="FORMFIELD_STATEFK_WARNING"
fkstate="com_mycomponent.parentGroup"
default="0"
class="readonly"
/>

and the field's code is:

class JFormFieldStatefk extends JFormField {
 
protected $type = 'statefk';
 
// getLabel() left out
 
public function getInput() {
$fk = JFactory::getApplication()->getUserState($this->element['fkstate'], $this->element['default']);
$input = '<input type="text" id="'.$this->id.'" name="'.$this->name.'"';
if ($this->class) {
$input .= ' class="'.$this->class.'"';
}
$input .= ' value="'.$fk.'"';
$input .= 'size="4" readonly="readonly" />';
return $input;
}
}

The error points to the __GET method which is a switch command and fkstate is obviously not in the list of switch options, but when I changed fkstate to value, I still got the error, and I should be able to have mine own properties in a custom field, right? 
 

Neo314

unread,
May 22, 2013, 1:48:47 AM5/22/13
to joomla-de...@googlegroups.com
Has no one seen this undefined property error before?

Neo314

unread,
May 22, 2013, 2:25:33 AM5/22/13
to joomla-de...@googlegroups.com
Found it. WHile the form element has $this-id and $this->name, I was referencing $this->class instead of $this->element["class"]
Reply all
Reply to author
Forward
0 new messages