3

I am deveoping a small plugin that needs to alter the registration and comment forms to add 4 hidden fields that have data inside that I gather from the configuration panel, and when the form is submitted, a js onlick event must be called to send those 4 hidden field data (it's a tracking software similar to google analytics).

So far I've built the xml manifest and xml field structure following this link and this link tutorials.

The first issue is that the fields are hidden, so the data is not entered by the user. I need to fill those fields data with:

<?php echo $params->get('my_param'); ?>

but on those tutorials I don't see any example on how to fill the fields when the form is loaded. I'm also lost on how to attach a js onclick event to the submit form. It is enough to implement onAfterRender()?

EDIT: The registration form is the one where an user register to the joomla cms. Joomla registration form The comment form is any comment form added by a third party extension below posts and pages.

  • 1
    which registration and comment forms? – Craig Jul 28 '14 at 23:13
  • cppl I hope to have answered your question. – Terix Jul 29 '14 at 13:48
  • would it be an option to use a ready built (free) component such as ChromoForms or RSForms? You can easily modify these with js events such as onload, onsumbit and ondisplay etc – jonboy Jul 29 '14 at 19:54
  • Unfortunately not. I need to develop a package that I distribute, I cannot rely on a third-party solution. – Terix Jul 29 '14 at 21:43
4

I think you will need onContentPrepareForm() for that, then you can load your fields in it. Here is a good tutorial how to make it.

To attach a js onclick event to the submit form, you will need to override form template and put your JS code inside.

  • the tutorial was perfect to help me add the fields. The issue is that I cannot change the template or I need to do it programmatically (with a plugin). There is any other way to add js to the form submit? – Terix Aug 27 '14 at 13:59
  • Unfortunately I do not know another method. – Dmitry Rekun Aug 28 '14 at 6:33

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.