DCA Template

Dieses Template enthält (fast) alle möglichen Optionen1 für die definition eines Modul-Eingabefeldes.

$GLOBALS['TL_DCA']['###TABLE###']['fields']['###FIELD###'] = array(
    // label for form field
    'label'=> &$GLOBALS['TL_LANG']['###TABLE###']['###LABLEARRAY###'],

    // explanation for form field
    # 'explanation'=> &$GLOBALS['TL_LANG']['###TABLE###']['###LABLEARRAY###'], #

    // type of form field
    // [text,password,textarea,select,checkbox,radio,radioTable,inputUni,
    // trbl,chmod,pageTree,fileTree,talbeWizard,listWizard,optionWizard,
    // moduleWizard,checkboxWizard]
    'inputType' => 'text',

    // default value for form field
    # 'default' => '###MIXED###', #

    // options for dropdown or radio
    # 'options' => ###ARRAY()###, #

    // options for dropdown or radio from a table
    # 'foreignKey' => '###TABLE###.CONCAT(###FIELD###, "\, ", ###FIELD###)', #

    // labels for options
    # 'reference' => &$GLOBALS['TL_LANG']['###TABLE###']['###LABLEARRAY###'] #

    // callback functions for each option
    # 'options_callback' => ###ARRAY()###, #

    // only visible when set so in group settings
    'exclude' => true,

    // sort settings [1-12]
    'flag' => 1,

    // length of sort string for flag 3 + 4
    # 'length' => ###INT###, #

    // adds field to search menu options
    # 'search' => true, #

    // adds field to sort menu options
    # 'sorting' => true, #

    // adds field to filter menu options (only works on first level elements, if tree design defined)
    # 'filter' => true, #

    // overwrite field creation routine with own function
    # 'input_field_callback' => ###ARRAY()###, #

    // executed on field creation, gives fieldvalue and DCA and awaits a new fieldvalue
    # 'load_callback' = ###ARRAY()###, #

    // executed when field is saved, gives fieldvalue and DCA and awaits a new fieldvalue
    # 'save_callback' = ###ARRAY()###, #

    // adds an additional value from an own function
    # 'wizard' => ###ARRAY()###, #

    // relation to parent table
    # 'relation' => ###ARRAY()###, #

    // evaluation and additional options
    'eval' => array(
        // css classes for field [w50,clr,wizard,long,m12]
        'tl_class' => 'w50',

        // css style for element
        # 'style' => ###STRING###, #

        // show icon for helpwizard next to field label
    	# 'helpwizard' => true, #

    	// make a field mandatory
        'mandatory' => true,

    	// maximum number of characters
        'maxlength' => 255,

        // minimum number of characters
        # 'minlength' => ###INT###, #

    	// allows multiple selection for text, dropdown, radio and checkbox (mandatory for last one)
        # 'multiple' => true, #

        // number of columns (only on 'textarea')
        # 'cols' => ###INT###, #

        // number of rows (only on 'textarea')
        # 'rows' => ###INT###, #

        // type and configuration for richtexteditor [tinyMCE,tinyFlash]
        # 'rte' => ###STRING###, #

        // define the used wraps for this field
        // [off,soft,hard]
        # 'wrap' => ###STRING###, #

        // show files inside folders of a fileTree
        # 'files' => true, #

        // only files can be selected in a fileTree
        # 'filesOnly' => true, #

        // only show certain filetypes in a fileTree [jpg,jpeg,png,gif,pdf]
        # 'extensions' => ###STRING###, #

        // special root path for a fileTree
        # 'path' => ###STRING###, #

        // defines if the selection for a fileTree is with [checkbox,radio]
        # 'fieldType' => ###STRING###, #

        // show blank option at the beginning of a dropdown
        # 'includeBlankOption' => true, #

        // label for the blank option
        # 'blankOptionLabel' => ###STRING###, #

        // sorts an option array with keys instead of values
        # 'findInSet' => true, #

        // size of a multientryfield or number of inputfields
        # 'size' => ###INT###, #

        // send form on value change
        # 'submitOnChange' = true, #

        // regular expression for entry check
        // [digit,alpha,alnum,extnd,prcnt,date,time,datim,email,friendly,url,phone]
        # 'rgxp' => ###STRING###, #

        // prohibit white spaces
        # 'nospace' => true, #

        // allow HTML tags
        # 'allowHtml' => true, #

        // keeps all (!) HTML tags as entered
        # 'preserveTags' => true, #

        // decodes HTML entities (always true when HTML is allowed)
        # 'decodeEntities' => true, #

        // saves the value with encryption
        # 'encrypt' => true, #

        // this field can only be selected once for the whole table
        # 'fallback' => true, #

        // will not save this field if empty
        # 'doNotSaveEmpty' => true, #

        // always save value, even if not changed
        # 'alwaysSave' => true' #

        // convert white space to underscores
        # 'spaceToUnderscore' => true, #

        // the value of this field has to be unique for this table
        # 'unique' => true, #

        // adds (true) or removes (fales) a slash at the end of a string
        # 'trailingSlash' => true, #

        // adds a date picker popup
        # 'datepicker' => true, #

        // defines if this field can be editet in frontend (only applies to tl_member)
        # 'feEditable' => true, #

        // appends (?) field to a certain type group (?) [personal,address,contact,login]
        # 'feGroup' => true, #

        // show field value in member list
        # 'feViewable' => true, #

        // don't copy this field with the data entry
        # 'doNotCopy' => true, #

        // dont show content of field (still visible in sourcecode)
        # 'hideInput' => true, #

        // type of value is boolean
        # 'isBoolean' => true, #

        // disables field (not supported by all field types)
        # 'disabled' => true, #

        // field is only readable (not supported by all field types)
        # 'readonly' => true
    ),
    // SQL column configuration
    'sql' => "varchar(255) NOT NULL default ''"
);

Feld ohne Datenbankanbindung

Wird für ein Feld die eval-Option doNotSaveEmtpy auf true gesetzt während gelichzeitig eine Callback-Funktion für save_callback definiert wird, welche immer einen leeren Wert liefert, kann verhindert werden, dass ein Feld seinen Wert in die Datenbank schreibt bzw. überhaupt ein Feld in der Datenbank benötigt.

'testfield' => array
(
    'label'                        => &$GLOBALS['TL_LANG']['tl_house']['testfield'],
    'inputType'                    => 'select',
    'options'                    => array('toll', 'besser', 'wow', 'crazy'),
    'save_callback' => array
    (
        array('tl_house', 'test_save_callback'), // <-- sollte mit return '' oder null zurückgeben
    ),
    'eval'                        => array
    (
        'doNotSaveEmpty'    => true, // <-- DAS im Zusammenspiel mit einem save_callback war des Rätsels Lösung!
        'submitOnChange'    => true,
    ),
),

 

  1. https://contao.org/de/manual/3.0/data-container-arrays.html []

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht.