element 'eval populate' echo does not work anymore

linque

Member
in the 'Eval populate', the 'echo' command was working in the previous version.
1712933222106.png


how can it works in the new version ?
 
Echo from eval populate should never have worked. The eval populate must return an array of options. You will need to insert the constant another way. I have used sourcerer to include things like this in the forms intro.
 
You should also be able to include it via the Web Asset Manager in the eval populate, but I have not tried it.
 
Echo from eval populate should never have worked. The eval populate must return an array of options. You will need to insert the constant another way. I have used sourcerer to include things like this in the forms intro.
I confirm the 'echo' command in 'eval populate' works with the version 3.10

a part of my code is :
$Db->setQuery("SELECT id,nom FROM table WHERE `sel`='Y' ORDER BY NOM");
$Libs = $Db->loadObjectList();
foreach ($Libs as $Lib) {
$options[] = JHTML::_('select.option', $Lib->id, $Lib->nom);
echo "-".$Lib->id;
if ($check_Libs_tab[$Lib->id]) {
echo '<SCRIPT>tableau_check.push("fabrikgrid_'.$Lib->id.'");</SCRIPT>';
}
}
return $options;
 
While it may have worked in F3 it will not work in F4. The Eval Populate is to return an array of options, that is all.
 
In F3, I pre-check some Item with JS using 'echo'
In F4, I don't understand how to flag 'selected' item to pre-check some of them.
I know what items I have to check via my database.
 
You should also update your $Db to
$db = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
 
As mentioned in another thread, us the Web Asset Manager to insert JavaScript to check the selected items.
 
I use :

$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->addInlineScript('content of inline1');

It works !
thank's a lot...
 
Back
Top