Normal code to add some field to the template is:

<field name="examplevalue" type="text" default="" label="Example value" description="" />

I need something like this but dynamicly, because of this needs i imported in backend of my template 1 js file which is: admin.js, i insert in my control group a new span element:

$('#attrib-example-control-group').append('<span id="addnewvalue">add new value</span>');

Then i added a new action for this button also trough admin.js:

$('#addnewvalue').on('click', function () {
    $('#attrib-example-control-group').append('<div class="control-group">\n\
        Example value: <input type="text" name="newexamplevalue" id="newexamplevalue" />\n\

What i tried:

  1. Give standard xml parameter for template fields <field>
  2. Tried to copy html output of already existing values, renamed it and tried to save

I have now method how i add this fields, but my problem is how to save it successful?

  • Are you adding your element under <fields name="params">? Feb 6, 2015 at 9:56
  • I tried so, but nothing was saved.
    – xxx
    Feb 6, 2015 at 10:39

1 Answer 1


I am not sure if you noticed, but fields have a specific naming convention, like:


But this will anyway not do it.

Joomla has a security mechanism in JControllerForm::save().

    // Test whether the data is valid.
    $validData = $model->validate($form, $data);

The posted data will be checked / validated against the XML with fields / parameters. Since you have not defined your field, it will be removed.

Have a look at the Repeatable form field type.

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.