2

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!

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

2 Answers 2

3

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.

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

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.


Content transferred from deleted answer (deleted via moderation) by @robjoyce:

Correction to my previous:
renderField works too. It's when you use the label and value separately that it will break.

[grammar/formatting improved by @mickmackusa]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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