Gute Tag zusammen,
ich versuche seit einiger Zeit ein eigenes Formularfeld zu erstellen. Mein Plan ist, dass ich um mehrere Formularfelder einen Wrapper (div) haben möchte. Hier ist der Code für das Start-Element. Das Feld kann man im Backend auswählen, Text in das Label-Feld eintragen und abspeichern. Nun wird im Backend das Label in der Übersicht des Formulars nicht angezeigt und im Frontend das Template nicht ausgegeben. Habe ich vielleicht irgendwas vergessen oder falsch eingetragen?
contao/config/config.php
PHP-Code:
$GLOBALS['TL_FFL']['pageStart'] = 'Contao\FormPageStart';
contao/dca/tl_form_field.php
PHP-Code:
$GLOBALS['TL_DCA']['tl_form_field']['palettes']['pageStart'] = '{type_legend},type;{fconfig_legend},label;{expert_legend:hide},class;{template_legend:hide},customTpl;{invisible_legend:hide},invisible';
contao/forms/FormPageStart.php
PHP-Code:
<?php
namespace Contao;
class FormPageStart extends Widget
{
/**
* Template
*
* @var string
*/
protected $strTemplate = 'form_pageStart';
/**
* Do not validate
*/
public function validate()
{
}
/**
* Parse the template file and return it as string
*
* @param array $arrAttributes An optional attributes array
*
* @return string The template markup
*/
public function parse($arrAttributes=null)
{
$request = System::getContainer()->get('request_stack')->getCurrentRequest();
if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
{
$objTemplate = new BackendTemplate('be_wildcard');
$objTemplate->title = $this->label;
return $objTemplate->parse();
}
return parent::parse($arrAttributes);
}
/**
* Generate the widget and return it as string
*
* @return string The widget markup
*/
public function generate()
{
return sprintf(
'<p>%s',
($this->label ? '<legend>' . $this->label . '</legend>' : '')
);
}
}
class_alias(FormPageStart::class, 'FormPageStart');
contao/template/forms/form_pageStart.html5
PHP-Code:
<fieldset<?php if ($this->class): ?> class="<?= $this->class ?>"<?php endif; ?>>
<?php if ($this->label): ?>
<legend><?= $this->label ?></legend>
<?php endif; ?>
</fieldset>
Gibt es über dem Thema vielleich ne Anleitung oder irgendwelche Informationen über die erstellung eines eigenen Formularsfeld?
Lesezeichen