0
votes

I am developing a Joomla 3 component. In my Joomla/administrator/components/com_component/models/forms/ I have an XML file which includes a field of type "category". I need this field to show one specific category and its sub categories only. How can I achieve that?

2

2 Answers

0
votes

You might do better using the SQL-field-type instead of the category field type, see here. In the sql-field type you can directly query #__categories:

<field name="myfield" type="sql" default="10" label="Select cateogry" 
query="SELECT id, title FROM #__categories where parent_id = 'x' and 
extension='com_content' and access='1' " key_field="id" value_field="title" >
<option value='x' >Your top-category</option>
</field>

You'll need to modify the parent_id='x' to match your parent category_id. Also I added the top-category as a static option on top. Might need further modifications, but you get the idea.

regards Jonas

-1
votes

I created a custom form field and used sql queries there which worked fine.