Skip to content

Commit

Permalink
Dev: fix (again) dropdown list
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Oct 16, 2016
1 parent 8b97701 commit b0a7aee
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
9 changes: 8 additions & 1 deletion application/helpers/qanda_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1303,8 +1303,9 @@ function do_list_dropdown($ia)
if (is_null($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]==='')
{
$sOptions .= doRender('/survey/questions/list_dropdown/rows/option', array(
'name'=> $ia[1],
'value'=>'',
'opt_select'=> ($dropdownSize) ? SELECTED : "",/* not needed : first one */
'opt_select'=> ($dropdownSize) ? SELECTED : "",/* needed width size, not for single first one */
'answer'=>gT('Please choose...')
), true);
}
Expand All @@ -1324,6 +1325,7 @@ function do_list_dropdown($ia)
}
// ==> rows
$sOptions .= doRender('/survey/questions/list_dropdown/rows/option', array(
'name'=> $ia[1],
'value'=>$ansrow['code'],
'opt_select'=>$opt_select,
'answer'=>$_prefix.$ansrow['answer'],
Expand Down Expand Up @@ -1366,6 +1368,7 @@ function do_list_dropdown($ia)

// ==> rows
$sOptGroupOptions .= doRender('/survey/questions/list_dropdown/rows/option', array(
'name'=> $ia[1],
'value'=>$optionarray['code'],
'opt_select'=>$opt_select,
'answer'=>flattenText($optionarray['answer'])
Expand All @@ -1392,6 +1395,7 @@ function do_list_dropdown($ia)

// ==> rows
$sOptions .= doRender('/survey/questions/list_dropdown/rows/option', array(
'name'=> $ia[1],
'value'=>$optionarray['code'],
'opt_select'=>$opt_select,
'answer'=>flattenText($optionarray['answer'])
Expand All @@ -1414,6 +1418,8 @@ function do_list_dropdown($ia)
}

$sOptions .= doRender('/survey/questions/list_dropdown/rows/option', array(
'name'=> $ia[1],
'classes'=>'other-item',
'value'=>'-oth-',
'opt_select'=>$opt_select,
'answer'=>flattenText($_prefix.$othertext)
Expand All @@ -1428,6 +1434,7 @@ function do_list_dropdown($ia)
}

$optionData = array(
'name'=> $ia[1],
'classes'=>'noanswer-item',
'value'=>'',
'opt_select'=> '', // Never selected
Expand Down
18 changes: 7 additions & 11 deletions application/views/survey/questions/list_dropdown/answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,30 @@

<!-- answer-->

<p class="question answer-item dropdown-item col-sm-4">
<label for="answer<?php echo $name; ?>" class="hide label">
<div class="<?php echo $coreClass ?> form-group form-inline">
<label for="answer<?php echo $name; ?>" class="sr-only control-label">
<?php eT('Please choose'); ?>
</label>
<select
class="form-control list-question-select"
name="<?php echo $name; ?>"
id="answer<?php echo $name; ?>"
<?php echo ($dropdownSize) ? "size=$dropdownSize" : "" ; ?>
onchange="<?php echo $checkconditionFunction; ?>(this.value, this.name, this.type);<?php echo $select_show_hide; ?>"
>
<?php
// rows/option.php
echo $sOptions;
?>

</select>

<?php
// rows/othertext.php
echo $sOther;
?>
<input
type="hidden"
name="java<?php echo $name; ?>"
id="java<?php echo $name; ?>"
value="<?php echo $value; ?>"
/>

<?php
// rows/othertext.php
echo $sOther;
?>
</p>
</div>
<!-- end of answer -->
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?>

<!-- option -->
<option value='<?php echo $value?>' <?php echo $opt_select;?> <?php if(isset($classes)):?> class="<?php echo $classes;?>" <?php endif;?> >
<option value='<?php echo $value?>' id='answer<?php echo $name.$value ?>' <?php echo $opt_select;?> <?php if(isset($classes)):?> class="<?php echo $classes;?>" <?php endif;?> >
<?php echo $answer;?>
</option>
<!-- end of option -->
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
<input
class="form-control"
type="text"
id="othertext<?php echo $name; ?>"
id="<?php echo $name; ?>othertext"
name="<?php echo $name; ?>other"
style='<?php echo $display; ?>'
value='<?php echo $value?>'
aria-labelledby='answer<?php echo $name."-oth-" ?>'
/>

<script>
Expand All @@ -26,11 +27,11 @@ class="form-control"
}
$(document).on("change","#answer<?php echo $name; ?>",function(){
if($("#answer<?php echo $name; ?>").val()!="-oth-"){
$("#othertext<?php echo $name; ?>").hide();
$("#othertext<?php echo $name; ?>").val("").trigger("keyup");
$("#<?php echo $name; ?>othertext").hide();
$("#<?php echo $name; ?>othertext").val("").trigger("keyup");
}else{
$("#othertext<?php echo $name; ?>").show();
$("#othertext<?php echo $name; ?>").focus();
$("#<?php echo $name; ?>othertext").show();
$("#<?php echo $name; ?>"othertext).focus();
}
});
</script>
Expand Down

1 comment on commit b0a7aee

@Shnoulle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using same id than single choice radio list.

Please sign in to comment.