Issue with pseudo fields when column is null

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 7, 2020   (RSS)

By tbcshifter - April 7, 2020 - edited: April 7, 2020

So it turns out there's a bug in that code sample that causes the :label pseudofield not to be populated on "options listed below" list type. This is my new code, but it may be more elegant to handle preventing this query directly in getListOptionsFromSchema().

elseif (@$fieldSchema['optionsType'] == 'table' && empty($selectedValues)) {
  $valuesToLabels = [];
}
else {
  $listOptions    = getListOptionsFromSchema($fieldSchema, null, false, $selectedValues);
  $values         = array_pluck($listOptions, '0');
  $labels         = array_pluck($listOptions, '1');
  $valuesToLabels = $listOptions ? array_combine($values, $labels) : [];
}

By daniel - April 7, 2020

Hi tbcshifter,

getListOptionsFromSchema() does have some cases where we do want to run the query without a WHERE condition, so I think your initial approach makes the most sense. I've added this to our build version for testing.

Thanks!

Daniel
Technical Lead
interactivetools.com