PHP version: 7.3.9
Mysql Ver 15.1 Distrib 10.4.6-MariaDB
I am using the default Joomla contacts component, with no changes or overrides. I have configured a number of custom fields my contacts. One of these custom fields is type
sql. It selects values from a custom database table and offers these to the user when they fill in a form, the sql form field configuration is below;
When I select one the values and save, some of the form inputs clear, but multiple values are sent to the database.
I created a short video with captions here.
I've also made a short video of the same issue but with different fields.
In the video you will see the output of
var_dump($form->getData()), I added this line to
plugins/system/fields/fields.php as recommended by @RobbieJackson. You can see the data disappear as I save the page, yet it remains in the database.
Another suggestion was to output the SQL query which is run to get the data. In
administrator/components/com_fields/models/field.php I added
echo $this->getDbo()->replacePrefix((string) $query) . "<br>"; in the method getFieldValues. The output is below;
When I copy and paste the first query into HeidiSql I can see the data, but it's not rendering on the form. The parish field data is in
In the file
administrator/components/com_fields/helpers/fields.php, in the
prepareForm() function there's a line
$value = $model->getFieldValue($field->id, $data->id); (around line 506), below this I've added
echo '<pre>' . var_export($value, true) . '</pre>';, the output is below;
As you can see the
parish field is
NULL in the form, but in the database there are five values.
In the video I switch between my site and HeidiSQL in order to query the contact i'm editing. You can see that the data is in the database, but won't display in the form until I delete some other fields.
I've reinstalled the Joomla core files and ran extensions > manage > fix. Still the same issue.
I have tried this same procedure on a clean install of Joomla 3.9.13 and there are no issues, works as expected. This is strange as both sites are on the same localhost environment, same version of Joomla, and I haven't made any changes to any core files.
I had the following third party components installed but I have since removed them.
- sp page builder
- admin tools
- akeeba backup
- Regular Labs - Cache Cleaner
Any idea why this would be happening or how I can troubleshoot?