Forums

form field named 'option' getting value substituted

andypooz 13 Jan, 2012
I am using chronoforms to add a payment form to my site, and a strange thing is happening. I have a field required by RBS's Worldpay service named "option", which I have set with a value of "0", but Joomla is changing that value to "com_content", which is the active component (as the form is placed within an article).
Is this a Joomla 'feature' to place the value of the active component in any form field named 'option'? Is there a way of preventing this? I'd like to be able to change the name of the form field to avoid this issue, but because it has to connect with an external system, I cannot be flexible with form field names.

<input type="hidden" name="option" value="0">
in the HTML is output as
<input type="hidden" name="option" value="com_content">

Never come accross this before and there doesn't seem to be any mention of it anywhere. I tried changing the value to "1" and the same thing happens. I even tried (foolishly) adding the value using a php variable, but of course that made no difference.

Anyone got any ideas?

Cheers
Andy
GreyHead 13 Jan, 2012
Hi Andy,

As you see Joomla! uses 'option' to identify the current component. Best to treat it as a 'reserved word' and not use it as an input name. What you can do as a workaround is to give the form input a different name and then transfer the value in a Custom Code action after the form submits. I think that will work safely (fingers crossed).
<?php
$form->data['option'] = $form->data['option_xxx'];
?>

Bob
andypooz 13 Jan, 2012
That did the job. Thanks very much Bob.
This topic is locked and no more replies can be posted.