View Full Version : conflict post help

12-01-2010, 07:00 AM
I have a registration form, wherein, it has a dropdown menu of pre-made questions to serve as secret questions. then I added a "write my own secret question" link wherein, if I click this link, it'll hide the dropdown menu and then show a textbox instead.

here's my jquery script

$ ('#ownSecret').hide();


here's the php code snippet

<div id="dropSecret" class="row">
<?php echo CHtml::activeLabelEx($form,'WSMembershipSecretQuestion'); ?>
<?php echo CHtml::activeDropDownList($form,'WSMembershipSecretQuestion',$form->getSecretQuestions()); ?>

<?php echo CHtml::link('write my own secret question','#',array('id'=>'ownSecret')); ?>

<div id="textSecret" class = "row">
<?php echo CHtml::activeLabelEx($form,'WSMembershipSecretQuestion'); ?>
<?php echo CHtml::activeTextArea($form,'WSMembershipSecretQuestion', array('rows' => 2,'cols' =>15)); ?>

<div class = "row">
<?php echo CHtml::activeLabelEx($form,'WSMembershipSecretAnswer'); ?>
<?php echo CHtml::activeTextField($form,'WSMembershipSecretAnswer'); ?>

now the problem is, this


the dropdown menu questionaire doesn't seem to get recognized when I submit the form..it only knows the text box version for writing own question when they both have the same attribute name :confused:

what should I do ?

12-01-2010, 01:51 PM
Rather than hiding the unused dropdown you could remove it (or still hide it, but also move it outside of the form so that it isn't included in the form validation).

Or you could dynamically create an option in the dropdown that is "throwaway" and set your PHP up to ignore the variable if the result is that throwaway value. You would still have a conflict if the name matches your new text box though.

Really, you have a number of possible solutions, but two form elements should not have the same name unless it is a radio switch.