Creating a custom form field type for Joomla XML fieldset
- Joel Lipman
- Joomla
- Hits: 15896
I'm writing a Joomla 2.5.x component for logging time and projects and need a dropdown to have selectable options restricted to the logged-in user. This is specified in the XML file of the custom Joomla component and needs some SQL dependent on some dynamic variables.
Why?
In Joomla, the XML type of "sql" is extremely limited. The component I'm making has to ensure user's can only see their own projects and not everyone's:
SELECT * FROM #__projects ORDER BY name -- yields all projects irrespective of which user is logged in
- SELECT * FROM #__projects ORDER BY name
- -- yields all projects irrespective of which user is logged in
SELECT * FROM #__projects WHERE user_id=<logged_in_user> ORDER BY name
- SELECT * FROM #__projects WHERE user_id=<logged_in_user> ORDER BY name
Please Note: This article focuses on a front-end form dropdown. If you would like to see how to do modals for the admin panel, see my article Joomla article modal with clear button for Joomla article selection.
How?