joomla 3.10 Contenttype form field type

35 views
Skip to first unread message

João Veríssimo

unread,
Mar 14, 2023, 12:44:57 PM3/14/23
to Joomla! General Development
Hello all,
I have a form in joomla with where parent_type input is of type contentType, and other field parent_id that allows to choose the id from the previous selected contentType.
This is a behavior that I can see in the menu component, there is magic with jquery but I'm not capable to replicate this behavior in my component.
Have someone implemented this in there component and can share with us all.
I appreciate all help you can send.
If the code is compatible with joomla 4 even better :) .

Thank you.
João Veríssimo

My form xml is like this.
<field  name="parent_type" type="contenttype"
                        label="ATTACH_PARENT_TYPE" description="ATTACH_PARENT_TYPE_DESCRIPTION"
       
    />
   <field  name="parent_id" type="text"
                        readonly="true" class="readonly"
                        label="ATTACH_PARENT_ID" description="ATTACH_PARENT_ID_DESCRIPTION"
                        filter="int"
       
                />

Mark Stanton

unread,
Mar 14, 2023, 1:07:55 PM3/14/23
to Joomla! General Development
Hi ,

Yes, complicated stuff, linked fields.  You do need the js stuff because it's triggered client side.

You could search for "joomla linked fields".  Found this answer, which looks pretty comprehensive.  Does it help you enough?

João Veríssimo

unread,
Apr 13, 2023, 10:02:04 AM4/13/23
to Joomla! General Development
Hello I have try something different, have all fields in the form and show and hide, with the showon filter.
Like this:
 <field name="parent_type" type="list" default="article" required="true" label="ATTACH_PARENT_TYPE" description="ATTACH_PARENT_TYPE_DESCRIPTION">
                        <option value="article">Article</option>
                        <option value="categorie">Categorie</option>
                        <option value="contact">Contact</option>
                        <option value="newsfeed">NewsFeed</option>
                        <option value="weblink">Weblink</option>
                </field>

                <field  name="parent_id" type="text"
                        readonly="true" class="readonly"
                        label="ATTACH_PARENT_ID" description="ATTACH_PARENT_ID_DESCRIPTION"
                        filter="int"
       
                />
                 <field
name="articleid"
                        type="modal_article"
                        label="COM_CONTENT_FIELD_SELECT_ARTICLE_LABEL"
                        description="COM_CONTENT_FIELD_SELECT_ARTICLE_DESC"
                        required="true"
                        select="true"
                        new="false"
                        edit="true"
                        clear="true"
                        showon="parent_type:article"
                        addfieldpath="/administrator/components/com_content/models/fields"
/>
                <field
name="categoryid"
                        type="modal_category"
                        label="JGLOBAL_CHOOSE_CATEGORY_LABEL"
                        description="JGLOBAL_CHOOSE_CATEGORY_DESC"
                        extension="com_content"
                        required="true"
                        select="true"
                        new="false"
                        edit="true"
                        clear="true"
                        showon="parent_type:categorie"
                        addfieldpath="/administrator/components/com_categories/models/fields"
/>
                <field
name="contactid"
                        type="modal_contact"
                        label="COM_CONTACT_SELECT_CONTACT_LABEL"
                        description="COM_CONTACT_SELECT_CONTACT_DESC"
                        required="true"
                        select="true"
                        new="false"
                        edit="true"
                        clear="true"
                        showon="parent_type:contact"
                        addfieldpath="/administrator/components/com_contact/models/fields"
/>
                <field
name="newsfeedid"
                        type="Modal_Newsfeed"
                        label="COM_NEWSFEEDS_FIELD_SELECT_FEED_LABEL"
                        description="COM_NEWSFEEDS_FIELD_SELECT_FEED_DESC"
                        required="true"
                        select="true"
                        new="false"
                        edit="true"
                        clear="true"
                        showon="parent_type:newsfeed"
                        addfieldpath="/administrator/components/com_newsfeeds/models/fields"
/>
                <field
name="weblinkid"
type="modal_weblink"
                        label="COM_WEBLINKS_FIELD_SELECT_WEBLINK_LABEL"
                        required="true"
                        select="true"
                        new="false"
                        edit="true"
                        clear="true"
                        showon="parent_type:weblink"
                        description="COM_WEBLINKS_FIELD_SELECT_WEBLINK_DESC"
                        addfieldpath="/administrator/components/com_weblinks/models/fields"
/>.
Reply all
Reply to author
Forward
0 new messages