Hallo Entwickler ich hätte da mal ne Frage die ihr mir sicher in Null komma Nichst beantworten könnt.
Im diesem Thread wurde danach gefragt wie eine Pflichtfeld deaktiviert werden kann.
Geht ja eigentlich ganz einfach per dca. Kurz nachgeschaut und auch gleich gefunden
PHP-Code:
$GLOBALS['TL_DCA']['tl_guestbook']['fields']['email']['eval']['mandatory'] = false;
Leider zeigte das keine Wirkung, dann habe ich mir die GuestBookForm (es handelt sich im übrigen um die Gästebuch Erweiterung) angeschaut und gesehen das hier in der compile Funktion das Formular gebaut wird.
PHP-Code:
protected function compile()
{
// Get front end user object
$this->import('FrontendUser', 'User');
// Access control
if ($this->protected && !BE_USER_LOGGED_IN)
{
if (!FE_USER_LOGGED_IN)
{
$this->Template->protected = true;
return;
}
$arrGroups = deserialize($this->groups);
if (is_array($arrGroups) && count(array_intersect($this->User->groups, $arrGroups)) < 1)
{
$this->Template->protected = true;
return;
}
}
// Form fields
$arrFields = array
(
'name' => array
(
'label' => $GLOBALS['TL_LANG']['GUESTBOOK']['gb_name'],
'name' => 'gbname',
'value' => trim($this->User->firstname . ' ' . $this->User->lastname),
'inputType' => 'text',
'eval' => array('mandatory'=>true, 'maxlength'=>128)
),
'email' => array
(
'label' => $GLOBALS['TL_LANG']['GUESTBOOK']['gb_email'],
'name' => 'gbemail',
'value' => $this->User->email,
'inputType' => 'text',
'eval' => array('rgxp'=>'email', 'mandatory'=>true, 'maxlength'=>128, 'decodeEntities'=>true, 'tl_class'=>'w50')
)
);
if (!$this->gb_disableURL)
{
$arrFields['website'] = array
(
'label' => $GLOBALS['TL_LANG']['GUESTBOOK']['gb_website'],
'name' => 'gbwebsite',
'value' => $this->User->website,
'inputType' => 'text',
'eval' => array('rgxp'=>'url', 'maxlength'=>128, 'decodeEntities'=>true,'tl_class'=>'w50')
);
}
Jetzt meine Frage, wie kann man das denn update sicher ändern? Gilt das DCA nur fürs Backend?
Lesezeichen