Re: [jgen] How to pass item id into customised JFormFieldList?

299 views
Skip to first unread message
Message has been deleted

Ove

unread,
Apr 18, 2013, 6:39:54 AM4/18/13
to joomla-de...@googlegroups.com, Lorisidae
I would try to get the id/pid from the Request.
The Joomla way:
JFactory::getApplication()->input->getInt('pid')

Mostly you don't have to override method getInput() only getOptions() in
your JFormFieldList override.

Ove

Lorisidae wrote On 18.04.2013 05:14:
> I am developing an admin component that has a form with a multi-select list. The default values of the list are retrieved from a joined database query - which depends on the ID of the selected item. How do I access the ID from within my extended JFormFieldList class?
>
> The general approach is as outlined in:
> http://docs.joomla.org/Creating_a_custom_form_field_type
>
> The XML file (../models/forms/xyz.xml) defines the field with multiple="true".
> The class file (../models/fields/abc.php) overrides getInput() and contains SQL to extract both the option list and the default values.
>
> Investigation so far has identified $this->element['pid'] as a vehicle for passing the parameter, but all the example for the accompanying XML I have found are for static values.
>
> So my question is: how do I dynamically assign the XML element ('pid') to have a value of $this->item->id as it is defined in the View (e.g. ../views/xyz/tmpl/edit.php)?
>
> Thanks in advance for your help!
>

Lorisidae

unread,
Apr 18, 2013, 6:16:52 PM4/18/13
to joomla-de...@googlegroups.com
Thank you Ove, that was what I needed - couldn't see the wood for the trees!

I found I needed to override getInput() to extract the default values
Reply all
Reply to author
Forward
0 new messages