Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eval Populate fails with SQL Error on Radio Button Element #2200

Open
JimKeaneUoH opened this issue Jun 12, 2020 · 0 comments
Open

Eval Populate fails with SQL Error on Radio Button Element #2200

JimKeaneUoH opened this issue Jun 12, 2020 · 0 comments

Comments

@JimKeaneUoH
Copy link

Prior to 3.9.2 the below used to work but now fails with an SQL null error:

$array_value = '{verbalr___get_questions}';
$local_array = explode(",", $array_value);
$question_number = $local_array[0];
$db = JFactory::getDbo();
$query = "SELECT label_1, value_1, label_2, value_2, label_3, value_3, label_4, value_4 FROM question_bank WHERE id = " . $question_number;
$db->setQuery($query);
$rows = $db->loadAssocList();

$options[] = JHTML::_('select.option', $rows[0]['value_1'], $rows[0]['label_1']);
$options[] = JHTML::_('select.option', $rows[0]['value_2'], $rows[0]['label_2']);
$options[] = JHTML::_('select.option', $rows[0]['value_3'], $rows[0]['label_3']);
$options[] = JHTML::_('select.option', $rows[0]['value_4'], $rows[0]['label_4']);

return $options;

{verbalr___get_questions} is populated via the form PHP Plugin onBeforeLoad successfully.

On working through this error it turned out that the data for {verbalr___get_questions} was not available to the Radio button element's Eval Populate at the time it ran. I got around this by getting the value using $this->getFormModel instead as so:
$array_value = $this->getFormModel()->data['verbalr___get_questions'];

However, this now fails on submit as $this->getFormModel is not available on submit, which leads me to this inelegant dual method which does work:

$array_value_form = '{verbalr___get_questions}';
$array_value_direct = $this->getFormModel()->data['verbalr___get_questions'];
if ($array_value_form == ''){$array_value = $array_value_direct;} else {$array_value = $array_value_form;}

I'm guessing this is a bug, and that my original implementation should have continued to work following the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant