Forums

more than one dropdown on a page

gluttonforpunishment 17 Nov, 2016
Hi

I am having a problem with displaying data in dropdowns. When i add more than one dropdown they seem to stop each other working. I am labelling each of them differently and have provided the code below. In this particular example the first dropdown should display dynamic data, in the second dropdown it should display a list of options. Initially the first dropdown worked however the second would not. Now i have managed to get the second to display data but the first dropdown will not display data even though i did not change anything. This has happened on all the forms that I have tried to show two dropdowns.

Has anyone come across this before? I am very new to chronoform and do not have a great understanding of the code. I also wondered if it could be another module in joomla causing it not to work?
<?php
$keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "project")), explode(".", "[n].projectid"));
$values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "project")), explode(".", "[n].projectname"));
$options = array_combine($keys, $values);
$field = array (
  'name' => 'project',
  'id' => 'project',
  'options' => 
  array (
    'value' => 'projectname',
  ),
  'empty' => '',
  'values' => 
  array (
  ),
  'label' => 
  array (
    'text' => 'Project',
    'position' => 'left',
  ),
  'sublabel' => '',
  'multiple' => '0',
  'size' => '',
  'class' => ' validate[\'required\']',
  'title' => '',
  'style' => '',
  'params' => '',
  ':data-load-state' => '',
  ':data-tooltip' => '',
  'type' => 'dropdown',
  'container_id' => '0',
);
$field["options"] = $options;
echo \GCore\Helpers\Html::formLine($field["name"], $field);
?><div class="form-group gcore-form-row" id="form-row-activitytype"><label for="activitytype" class="control-label gcore-label-left">Activity type</label>
<div class="gcore-input gcore-display-table" id="fin-activitytype"><select name="activitytype" id="activitytype" size="" class="validate['required'] form-control A" title="" style="" data-load-state="" data-tooltip="">
<option value="document_reviewers">Document reviewers</option>
<option value="forums">Consumer and Community Forums and Conversations</option>
<option value="consumer_rep">Consumers and community members in research teams</option>
<option value="buddy">Research buddy</option>
<option value="ref_grp">Reference group</option>
<option value="steering_grp">Steering group</option>
<option value="ccres">Consumer and community researchers</option>
<option value="ccac">Consumer and community advisory council</option>
<option value="expo">Community expo</option>
<option value="psp">Priority setting partnership</option>
GreyHead 17 Nov, 2016
Hi gluttonforpunishment,

Why and where are you using all of that code?

I assume that you've only posted part of it as there is only one drop-down there and that doesn't have a closing </select> tag.

Are the two drop-downs supposed to be linked in some way?

Bob
gluttonforpunishment 18 Nov, 2016
1 Likes
Hi Bob,

I actually just copied the code from the wizard rather than have lots of screen shots. I have actually managed to get it to work working through some of the things you suggested in the message you sent. I renamed all of the dropdown to ensure that there were none that were the same across all my forms and it seems to have worked.

Thanks
GreyHead 18 Nov, 2016
Hi gluttonforpunishment,

Well done :-)

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount

{item:title} {images:#}