1

I tried to look around, but didn't exactly found what I was looking for. Joomla have documentation about how to create custom form fields. That was useful, but what I need is (I guess simple..?).

I want to have custom form field for backend component. Just a simple input text field with two options - add/delete. When you press add I get additional text field, if I want to delete - it simply removes. I want to understand how to do this. Thank you!

  • 2
    You could always wait until Joomla 3.7 when custom form fields will be shipped with core. – Lodder Mar 23 '17 at 17:23
  • @Lodder When will Joomla 3.7 be launched? I am already using 3.7 beta version. – Poo123 Mar 24 '17 at 8:06
  • Not sure, there's still a lot of working happening on custom fields – Lodder Mar 24 '17 at 10:14
2

I am using the following to achieve something similar to what you need BUT in a plugin. Need to confirm if it is also valid to component.

            <field
                name="list_field_name"
                type="list"
                class="inputbox"
                label="LIST_FIELD_NAME_LABEL"
                description="LIST_FIELD_NAME_DESC"
                default="add"
                size="1">
                <option value="add">add</option>
                <option value="delete">delete</option>
            </field>
            <field
                name="text_field_name"
                type="text"
                class="inputbox"
                showon="list_field_name:add"
                label="TEXT_FIELD_NAME_LABEL"
                description="TEXT_FIELD_NAME_DESC"
                size="40"
                filter="string" />

The use of showon let you conditionally show the field. Hope it helps.

  • Can you please give me full example? File name/location/calling it ect. ? Thanks in advance @n.h. – Poo123 Mar 23 '17 at 14:28
  • Use it in the manifest xml file. See – n.h. Mar 23 '17 at 14:48
  • @Poo123 More details about it here – n.h. Mar 28 '17 at 9:12
0

From my experience. onshow ONLY works if you use renderFieldSet if you use renderField it won't work. it seems that the whole fieldset needs to be shown at the same time so that JForm can link the fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.