Ist es möglich unter Formulare einen eigenen Feldtyp zu erstellen? Hab angenommen das das ähnlich funktioniert wie bei einem Content Element aber finde dazu nichts weiter.
Ist es möglich unter Formulare einen eigenen Feldtyp zu erstellen? Hab angenommen das das ähnlich funktioniert wie bei einem Content Element aber finde dazu nichts weiter.
Habe es jetzt noch nicht ausprobiert, aber müsste eigentlich so funktionieren.
Musst die $GLOBALS['TL_FFL'] mit deinem Feld erweitern z.B so:
Und dann müsste das Feld noch konfiguriert werden.PHP-Code:
array:15 [?
"explanation" => "Contao\FormExplanation"
"html" => "Contao\FormHtml"
"fieldsetStart" => "Contao\FormFieldsetStart"
"fieldsetStop" => "Contao\FormFieldsetStop"
"text" => "Contao\FormTextField"
"password" => "Contao\FormPassword"
"textarea" => "Contao\FormTextArea"
"select" => "Contao\FormSelectMenu"
"radio" => "Contao\FormRadioButton"
"checkbox" => "Contao\FormCheckBox"
"upload" => "Contao\FormFileUpload"
"range" => "Contao\FormRange"
"hidden" => "Contao\FormHidden"
"captcha" => "Contao\FormCaptcha"
"submit" => "Contao\FormSubmit",
"yourField" => "Vendor\FormField"
]
Dafür kannst du dir ein Beispiel bei bestehenden Feldern nehmen:
Pfad:Code:/contao/vendor/contao/core-bundle/src/Resources/contao/forms/FormExplanation.phpPHP-Code:
<?php
/*
* This file is part of Contao.
*
* (c) Leo Feyer
*
* @license LGPL-3.0-or-later
*/
namespace Contao;
/**
* Class FormExplanation
*
* @property string $text
*/
class FormExplanation extends Widget
{
/**
* Template
*
* @var string
*/
protected $strTemplate = 'form_explanation';
/**
* The CSS class prefix
*
* @var string
*/
protected $strPrefix = 'widget widget-explanation';
/**
* Do not validate
*/
public function validate()
{
}
/**
* Generate the widget and return it as string
*
* @return string The widget markup
*/
public function generate()
{
// Add the static files URL to images
if ($staticUrl = System::getContainer()->get('contao.assets.files_context')->getStaticUrl())
{
$path = System::getContainer()->getParameter('contao.upload_path') . '/';
$this->text = str_replace(' src="' . $path, ' src="' . $staticUrl . $path, $this->text);
}
return StringUtil::encodeEmail($this->text);
}
}
class_alias(FormExplanation::class, 'FormExplanation');
als Anregung: https://easysolutionsit.de/artikel/c...d-widgets.html
MetaModels-Workshop: ... wo sich die nächste Gelegenheit bietet... oder Extern oder Online
Erweiterungen: Infos im Seitenbaum, Formular-Default für Select/Checkbox/Radio (SCR), Formular-Newsletteranmeldung, Regex-Formularwidget, Lizenzmanager für Isotope
Unterstützung per Github-Sponsoring: MetaModels Handbuch und Forum, e-spin Erweiterungen
Danke euch hat sich dann erledigt :)
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
Lesezeichen