1

I need to expand the functionality of the registration form. Following some tutorials and the sample profile plugin I was able to use the onContentPrepareForm to add the new fields.

Now the second part is that they need to be sorted in a specific order using some of the default fields. I created a template override and had it just how I wanted. However, 2 of the new fields have the showon functionality. Meaning that on 2 different places a field will display only if the value of the previous field matches a specific value. I noticed that although it was working on the backend, on the frontend it wasn't working; the conditional fields would always display. After doing some research and looking at the backend code (where it was working) I noticed that the showon feature only works when the fields are rendered using the renderField method. Simple enough I though I could just run the method on each of my fields in the correct order. Here is where my problem is at. I can render only the default fields (name, username, password). None of my custom fields get rendered using this method. When I loop through each field and run the renderField() method they all work.

        foreach ($fields as $field) {
                echo $field->renderField();             
        }

However, when I try to render each individually by name using $form->renderField('field') the custom fields don't get rendered. I tried using the name I gave them in the form.xml file, I tried using jform[field], jform_field but nothing works. Even when I try using $this->form->getField('fieldname') I don't get the field back on any of my custom fields only the original fields.

I think this might have to do with the plugin and the field names not being available, but I'm not sure. I'm fairly new to Joomla so I'm still trying to figure things out.

Any help would be appreciated, thanx!

1 Answer 1

1

OK, I finally got it to work looking through this page again.

To display one of the default fields I just had to enter renderField('name_of_field'), but to display one of the custom fields I have to add a second parameter, which is the group name of the fields. In my case I kept the group name the same as the sample plugin--profile. So I had to enter renderField('name_of_field', 'profile')

Your Answer

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

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