Meine Klasse funktioniert nun in der Anzeige wie gewünscht. Leider habe ich das Problem, dass die Validierung der Daten nicht richtig erfolgt. Zumindest erhalte ich immer eine Fehlermeldung, dass die Eingabe ungültig war. Die '102' ist der übermittelte 'value'-Wert der Option.
Meldung:
Code:
Warning: Invalid argument supplied for foreach() in system/modules/core/library/Contao/Widget.php on line 1174
#0 system/modules/core/library/Contao/Widget.php(1174): __error(2, 'Invalid argumen...', '/www/htdocs/w00...', 1174, Array)
#1 system/modules/core/forms/FormSelectMenu.php(126): Contao\Widget->isValidOption('102')
#2 system/modules/core/forms/Form.php(174): Contao\FormSelectMenu->validate()
#3 system/modules/core/classes/Hybrid.php(218): Contao\Form->compile()
#4 system/modules/core/forms/Form.php(56): Contao\Hybrid->generate()
#5 system/modules/core/library/Contao/Controller.php(295): Contao\Form->generate()
#6 system/modules/core/pages/PageRegular.php(138): Contao\Controller->getFrontendModule(Object(Contao\ModuleModel), 'right')
#7 index.php(249): Contao\PageRegular->generate(Object(Contao\PageModel), true)
#8 index.php(432): Index->run()
#9 {main}
FormSelectMenu.php - hier wird der Fehler ausgeben:
PHP-Code:
// Check for a valid option (see #4383)
if (!empty($varInput) && !$this->isValidOption($varInput))
{
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalid'], (is_array($varInput) ? implode(', ', $varInput) : $varInput)));
}
Hier die Überprüfung in der Widget.php
PHP-Code:
protected function isValidOption($varInput)
{
if (!is_array($varInput))
{
$varInput = array($varInput);
}
// Check each option
foreach ($varInput as $strInput)
{
$blnFound = false;
foreach ($this->arrOptions as $v)
{
// Single dimensional array
if (array_key_exists('value', $v))
{
if ($strInput == $v['value'])
{
$blnFound = true;
}
}
Ich möchte schlicht alle Optionen des Select-Menüs vorgeben. Was mache ich falsch?
Lesezeichen