Hello everybody,
I have searched in lot of topics but I didn't find my answer...
So I'm here๐
I have a form who display a tab (make by my custom code). One row for each biological sample.
In each row, I want to display a dropdown (named sampleDropdown for this topic).
I have a first dropdown before the tab. In this dropdown (named firstDropdown) I can choose between different values. The sampleDropdown is dynamic (double-dropdown with firstDropdown).
My problem is:
I select a value in my firstDropdown.
In my tab, The first row is displayed correctly (I have my sampleDropdown with several choice).
But the others rows are displayed with an empty dropdown.
There is a part of my custom code and some pictures
Thanks for your help Chronoforms community (and GreyHead ๐ )
Ludo
I have searched in lot of topics but I didn't find my answer...
So I'm here๐
I have a form who display a tab (make by my custom code). One row for each biological sample.
In each row, I want to display a dropdown (named sampleDropdown for this topic).
I have a first dropdown before the tab. In this dropdown (named firstDropdown) I can choose between different values. The sampleDropdown is dynamic (double-dropdown with firstDropdown).
My problem is:
I select a value in my firstDropdown.
In my tab, The first row is displayed correctly (I have my sampleDropdown with several choice).
But the others rows are displayed with an empty dropdown.
There is a part of my custom code and some pictures
Thanks for your help Chronoforms community (and GreyHead ๐ )
Ludo
<?php
/** Code for the sampleDropdown **/
$keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "kitListModel")), explode(".", "[n].idKit_list"));
$values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "kitListModel")), explode(".", "[n].barecodeKit_list,sequenceKit_list"));
$options = array_combine($keys, $values);
$field = array (
'name' => 'barecodeKit[]',
'id' => 'barecodeKit',
'options' =>
array (
),
'empty' => '',
'values' =>
array (
),
'label' =>
array (
'text' => 'Test contenu Kit',
'position' => 'left',
),
'sublabel' => '',
'multiple' => '0',
'size' => '',
'class' => '',
'title' => '',
'style' => '',
'params' => '',
':data-load-state' => '',
':data-tooltip' => '',
'type' => 'dropdown',
'container_id' => '13',
);
$field["options"] = $options;
//echo \GCore\Helpers\Html::formLine($field["name"], $field);
?>
<!-- Custom code to display table with data and sampleDropdown -->
<table style="width:100%">
<tr>
<th><strong>idEch</strong></th>
<th><strong>idTubeClient</strong></th>
<th><strong>typeEch</strong></th>
<th><strong>Barecode</strong></th>
</tr>
<?php
/** display each row **/
foreach ( $form->data['idRecep'] as $v ) {
echo '<tr>';
$db = \JFactory::getDBO();
$query = "SELECT * FROM echantillon_input WHERE idEch =".$v."";
$db->setQuery($query);
$serial = $db->loadAssocList();
$barecode = 1;
foreach ( $serial as $s ) {
$barecode += 1;
echo '<td>';
echo $s['idEch'];
echo '</td>';
echo '<td>';
echo $s['idTubeClient'];
echo '</td>';
echo '<td>';
echo $s['typeEch'];
echo '</td>';
echo '<td>';
/** This is the code who display the dynamic dropdown sampleDropdown **/
echo \GCore\Helpers\Html::formLine($field["name"], $field);
echo '</td>';
}
echo '</tr>';
}
?>
</table>