Access custom attributes in a custom field in JFormField

I created a custom field type in Joomla and you need to pass parameters to it. For example, my JForm XML file looks like this:

<?xml version="1.0" encoding="utf-8"?> <form> <fieldset addfieldpath="/administrator/components/com_gallery/models/fields"> <field name="images" type="MultiImage" label="Images" description="" imagetable="#__gallery_images" imagedir="../images/gallery/originals/" /> </fieldset> </form> 

And I want to access imagetable and imagedir in my custom field:

 <?php // No direct access to this file defined('_JEXEC') or die; jimport('joomla.form.formfield'); class JFormFieldMultiImage extends JFormField { protected $type = 'MultiImage'; public function getInput() { //this is where i want to access it $input = $this->imagetable; return $input; } } 

I assumed that you just used $this->attributename , and when I var_dump($this) , I see that the attributes are defined, but they are :protected .

I would appreciate help on this :)

Thanks Tom

+4
source share
1 answer

You are so close! Try this and let me know if this works for you because it works for me. (Joomla 2.5.6)

 echo $this->element['imagedir']; echo $this->element['imagetable']; 
+6
source

All Articles