-
Error: Non-static method
Hallo zusammen,
ich hatte vor einiger Zeit unter PHP 7.4 und Contao 4.12.3 die Erweiterung yds_visualformfields installiert (manuell als Modul), um Bilder als Checkboxen oder Radio Buttons anzeigen zu lassen. Nach dem Update auf Contao 4.12.7 und PHP 8.1 kommt nun folgende Fehlermeldung:
request.CRITICAL: Uncaught PHP Exception Error: "Non-static method VisualFormFields::createImage() cannot be called statically" at /www/htdocs/xxxxxxxxxx/meinedomain.de/system/modules/yds_visualformfields/CheckBoxVisual.php line 54 {"exception":"[object] (Error(code: 0): Non-static method VisualFormFields::createImage() cannot be called statically at /www/htdocs/xxxxxxxxxx/meinedomain.de/system/modules/yds_visualformfields/CheckBoxVisual.php:54)"} []
Der betreffende Abschnitt ist hier:
PHP-Code:
* Generate the widget and return it as string
* @return string
*/
public function generate()
{
$strImage = VisualFormFields::createImage('mod_visual_formfields_img', $this, $this->singleSRC, $this->strLabel, $this->strLabel);
$strBuffer = '';
$strChecked = ($this->is_selected) ? 'checked="checked"' : '';
Was muss ich hier ändern, damit das Formular wieder funktioniert? Mit PHP kenne ich mich nicht besonders gut aus.
Gruß
Robert
-
Hat keiner eine Lösung? Wenn ich diesen Fehler Non-static method beseitige, erhalte ich aber die Meldung
Uncaught PHP Exception Error: "Call to protected Contao\Backend::__construct() from scope CheckBoxVisual" at /www/htdocs/xxxxxxxx/meinedomain.de/system/modules/yds_visualformfields/CheckBoxVisual.php line 55 {"exception":"[object] (Error(code: 0): Call to protected Contao\\Backend::__construct() from scope CheckBoxVisual at /www/htdocs/xxxxxxxxxx/meinedomain.de/system/modules/yds_visualformfields/CheckBoxVisual.php:55)"} []
Der Ersteller des Moduls antwortet leider nach mehrmaliger Nachfrage nicht.
-
Hmmm, das ist wohl keine öffentliche Erweiterung. Mit Code Schnipseln wird es u.U. recht schwierig zu analysieren, was da nicht korrekt ist.
Im Endeffekt ist PHP 8 auf jeden Fall deutlich restriktiver als PHP 7. D.h. Syntaxfehler sind dann deutlich schwerwiegender.
-
PHP-Code:
Uncaught PHP Exception Error: "Call to protected Contao\Backend::__construct() from scope CheckBoxVisual"
at /www/htdocs/xxxxxxxx/meinedomain.de/system/modules/yds_visualformfields/CheckBoxVisual.php line 55
{ "exception":
"[object] (Error(code: 0): Call to protected Contao\\Backend::__construct()
from scope
CheckBoxVisual at
/www/htdocs/xxxxxxxxxx/meinedomain.de/
system/modules/yds_visualformfields/CheckBoxVisual.php:55)"
} []
Habe das Plugin über Google gefunden (https://www.your-d-sign.de/de/leistu...ual-formfields) und meine Änderungen sind ungetestet.
Folgende Fehler können unter PHP 8.1 auftreten und müssen in folgenden Klassen folgendermaßen geändert werden:
In yds_visualformfields/CheckBoxVisual.php - Zeile 54
von:
PHP-Code:
$strImage = VisualFormFields::createImage('mod_visual_formfields_img', $this, $this->singleSRC, $this->strLabel, $this->strLabel);
zu:
PHP-Code:
$strImage = (new VisualFormFields)->createImage('mod_visual_formfields_img', $this, $this->singleSRC, $this->strLabel, $this->strLabel);
___
In yds_visualformfields/ImageVisual.php - Zeile 54
von:
PHP-Code:
$strImage = VisualFormFields::createImage('mod_visual_formfields_img', $this, $this->singleSRC, $this->strLabel, $this->strLabel);
zu:
PHP-Code:
$strImage = (new VisualFormFields)->createImage('mod_visual_formfields_img', $this, $this->singleSRC, $this->alt, $this->title);
___
In yds_visualformfields/RadioVisual.php - Zeile 55
von:
PHP-Code:
$strImage = (new VisualFormFields)->createImage('mod_visual_formfields_img', $this, $this->singleSRC, $this->strLabel, $this->strLabel);
zu:
PHP-Code:
$strImage = (new VisualFormFields)->createImage('mod_visual_formfields_img', $this, $this->singleSRC, $this->strLabel, $this->strLabel);
Eine Weitere Info: Das Plugin ist nicht auf GitHub und wird mit Contao 5.0 definitiv nicht funktionieren.
Diese Änderungen müssen erfolgen, damit die Errors nicht mehr auftreten (ungetestet)
___
Aufgrund keiner vorhandenen Lizenz müsste man diese Änderungen (als eigene Person) manuell durchführen.
Die Extension scheint auch veraltet zu sein, ein Update wird es demnach eventuell auch nicht geben.
-
Ich danke Dir für die Antwort, Zoglo. Das Ändern der Zeile in (new VisualFormFields...) hatte ich auch schon probiert. Jedoch kommt dann die im Beitrag angegebene Meldung: "Call to protected Contao\Backend::__construct() from scope CheckBoxVisual".
Es gibt noch das Modul "Visual Radio Bundle", das man im Contao Manager installieren und auch auf GitHub herunterladen kann. Allerdings habe ich vergeblich das Formularfeld mit dem visuellen Radio-Feld beim Anlegen des Formulars gesucht. Hat da jemand Erfahrung mit dieser Erweiterung? Wie bekomme ich das Radio Auswahlfeld mit dem Bild, das dann dazu angezeigt wird, ins Formular? Da das auch mit PHP 8 funtioniert, wäre es eine Alternative zu VisualFormFields.