Skip to content

Commit

Permalink
Get the field value already loaded by getFields() (#42861)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
Co-authored-by: Benjamin Trenkle <bembelimen@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 30, 2024
1 parent a7f5e50 commit ef41412
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions administrator/components/com_fields/src/Helper/FieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,24 +485,14 @@ public static function prepareForm($context, Form $form, $data)
// Loading the XML fields string into the form
$form->load($xml->saveXML());

$model = Factory::getApplication()->bootComponent('com_fields')
->getMVCFactory()->createModel('Field', 'Administrator', ['ignore_request' => true]);

if (
(!isset($data->id) || !$data->id) && Factory::getApplication()->getInput()->getCmd('controller') == 'modules'
&& Factory::getApplication()->isClient('site')
) {
// Modules on front end editing don't have data and an id set
$data->id = Factory::getApplication()->getInput()->getInt('id');
}

// Looping through the fields again to set the value
if (!isset($data->id) || !$data->id) {
return true;
}

foreach ($fields as $field) {
$value = $model->getFieldValue($field->id, $data->id);
// Get the value already loaded by static::getFields()
$value = $field->rawvalue;

if ($value === null) {
continue;
Expand Down

0 comments on commit ef41412

Please sign in to comment.