Chrono nOOb here
I can successfully use dynamic dropdowns - from a multi-read - and write the user selection to my data table.
Next up I need to read that row and mark the relevant option as SELECTED.
I have both dbreads but I don't see any obvious hook back into the form.
If this were just native PHP I could wing it, but echo \GCore\Helpers\Html::input($field["name"], $field); doesn't leave me any control. Is my only way in writing my own loop?
Thanks!
I can successfully use dynamic dropdowns - from a multi-read - and write the user selection to my data table.
Next up I need to read that row and mark the relevant option as SELECTED.
I have both dbreads but I don't see any obvious hook back into the form.
If this were just native PHP I could wing it, but echo \GCore\Helpers\Html::input($field["name"], $field); doesn't leave me any control. Is my only way in writing my own loop?
Thanks!
Hi kavalec,
If the drop-down exists in your form and has the same name as the data you are loading then the value will automatically e selected. The problem with a dynamic drop-down is that the drop-down may not exist - or not with the correct set of options added. In that case your On Load event needs to check the value of the first drop-down, and load the corresponding option set for the second one. Then the automatic selection will work OK.
Bob
If the drop-down exists in your form and has the same name as the data you are loading then the value will automatically e selected. The problem with a dynamic drop-down is that the drop-down may not exist - or not with the correct set of options added. In that case your On Load event needs to check the value of the first drop-down, and load the corresponding option set for the second one. Then the automatic selection will work OK.
Bob
Hi Bob
If the drop-down exists in your form and has the same name as the data you are loading then the value will automatically be selected.
That didn't seem to be happening, so this is what I did in the custom code
Note: subjectlist is the multi-read from the subjects, StudentSubs is the dbread of the previously saved rec.
If there is/was an automatic way to make this work, is there an example?
Thanks!
If the drop-down exists in your form and has the same name as the data you are loading then the value will automatically be selected.
That didn't seem to be happening, so this is what I did in the custom code
Note: subjectlist is the multi-read from the subjects, StudentSubs is the dbread of the previously saved rec.
If there is/was an automatic way to make this work, is there an example?
Thanks!
<div class="form-group gcore-form-row" id="form-row-multi-13">
<div class="gcore-subinput-container" id="fitem-SubjectSelected1">
<label for="SubjectSelected1" class="control-label gcore-label-left required_label">Please select your first subject (required) <i class="fa fa-asterisk" style="color:#ff0000; font-size:9px; vertical-align:top;"></i></label>
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-SubjectSelected1">
<?php
$keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "subjectlist")), explode(".", "[n].cf_id"));
$values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($form->data, explode(".", "subjectlist")), explode(".", "[n].Subject"));
$myoptions = array_combine($keys, $values);
echo '<select name="SubjectSelected1" id="SubjectSelected1" size="0" class="validate[\'required\'] form-control A" title="" style="" data-load-state="" data-tooltip="">';
$thisSelect = $form->data['StudentSubs']['SubjectSelected1'];
displaySelection($myoptions, $thisSelect );
echo '</select>';
echo '<p>'.$thisSelect.'</p>';
function displaySelection($options, $opt) {
echo '<option value="">';
foreach($options as $key=>$data) {
if ($key == $opt) {
$selected = 'Selected';
} else {
$selected = '';
}
echo '<option value="'.$key.'"' .$selected. '>' .$data.'</option>';
}
}
?>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-SubjectSelected2">
<label for="SubjectSelected1" class="control-label gcore-label-left required_label">Please select your second subject (optional)</label>
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-SubjectSelected2">
<?php
echo '<select name="SubjectSelected1" id="SubjectSelected2" size="0" title="" style="" data-load-state="" data-tooltip="">';
$thisSelect = $form->data['StudentSubs']['SubjectSelected2'];
displaySelection($myoptions, $thisSelect );
echo '</select>';
echo '<p>'.$thisSelect.'</p>';
?>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-SubjectSelected2">
<label for="SubjectSelected1" class="control-label gcore-label-left required_label">Please select your third subject (optional)</label>
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-SubjectSelected3">
<?php
echo '<select name="SubjectSelected1" id="SubjectSelected3" size="0" title="" style="" data-load-state="" data-tooltip="">';
$thisSelect = $form->data['StudentSubs']['SubjectSelected3'];
displaySelection($myoptions, $thisSelect );
echo '</select>';
echo '<p>'.$thisSelect.'</p>';
?>
</div>
</div>
</div>
<div class="form-group gcore-form-row" id="form-row-Submit"><div class="gcore-input gcore-display-table" id="fin-Submit"><input name="Submit" id="Submit" type="submit" value="Submit" class="btn btn-default form-control A" style="" data-load-state="" /></div></div>
Hi kavalec,
I cant work out how this is set up. You appear to have three drop-downs with the same name (but different IDs). That won't work as only the value from the last one will be submitted.
If you give them different names, or an array name then they will work and all the results will be submitted.
I think that you don't need most of this custom code. You can use the Dynamic Data settings in the drop-down events to load the options set; and the values in the $form->data array will set the selections - just how depends on the the format the data is being loaded in.
Bob
I cant work out how this is set up. You appear to have three drop-downs with the same name (but different IDs). That won't work as only the value from the last one will be submitted.
If you give them different names, or an array name then they will work and all the results will be submitted.
I think that you don't need most of this custom code. You can use the Dynamic Data settings in the drop-down events to load the options set; and the values in the $form->data array will set the selections - just how depends on the the format the data is being loaded in.
Bob
[attachment=1]create.jpg[/attachment][attachment=0]form.jpg[/attachment]OK
I am starting this form, and it's table, from scratch.
I add three dropdowns: SubjectSel1, SubjectSel2, and SubjectSel3
Save the form, delete the cache, and try to create table.
The added fields don't happen. And I suspect this is where my problems begin.
See attached screenshots. What am I doing wrong?
I am starting this form, and it's table, from scratch.
I add three dropdowns: SubjectSel1, SubjectSel2, and SubjectSel3
Save the form, delete the cache, and try to create table.
The added fields don't happen. And I suspect this is where my problems begin.
See attached screenshots. What am I doing wrong?
This topic is locked and no more replies can be posted.
