contao-community-alliance / contao-multicolumnwizard-bundle

Contao 4 Widget - MultiColumnWizard
GNU Lesser General Public License v3.0
12 stars 12 forks source link

"Default" funktioniert nicht #83

Open zonky2 opened 4 years ago

zonky2 commented 4 years ago

Auch wenn man einem Feld einen Default-Wert zuweist, wird dieser nicht ausgegeben.

siehe https://github.com/menatwork/MultiColumnWizard/issues/260

Typen lt. https://docs.contao.org/dev/reference/dca/fields/#reference bei inputType

Die Folgenden Widgets machen keinen Sinn:

Total-Reality commented 3 years ago

Doch funktioniert in Version 3.4.9 - Getestet mit Text und Textarea.

zonky2 commented 3 years ago

dann bitte alle testen...

Total-Reality commented 3 years ago

Okay, ich hab alle durchgetestet, die meiner Meinung nach Sinn ergeben haben. Gibt es eigentlich irgendwo eine Liste welche Felder der MCW überhaupt unterstützt?

Folgendes funktioniert mit Default-Festlegung:

Folgendes ging nicht, aber vielleicht geht das in Contao selbst auch nicht?

Folgendes hab ich ausgetestet, scheint nicht zu gehen, aber ergibt ohnehin keinen Sinn, dass man dann 2 Felder statt 1 erhält:

Bei folgendem Feld weiß ich nicht wie man einen default Wert definiert, auch wenn ich es durchaus interessant finden würde, wenn das gehen würde:

Fehlen jetzt noch irgendwelche Felder? https://docs.contao.org/dev/reference/dca/fields/ picker z.B. hab ich nicht zum Laufen bekommen, da braucht er wohl irgendwie eine Tabelle - wie auch immer man die übergibt?!

Code zum Testen für euch folgt:

$GLOBALS['TL_DCA'][$strTblName]['fields']['mcwtest2'] = array
(
    'exclude'   => true,
    'inputType' => 'multiColumnWizard',
    'eval'      => array
        (
        //'columnsCallback' => array('tl_mcw_test', 'getTestFields'),
        'columnFields' => array
                (
                    'text' => array
              (
                'label'              => 'text',
                'default'            => 'Bla',
                'inputType'          => 'text',
                'eval'               => array('rgxp'=>'digit', 'maxlength'=>5, 'style'=>'width:50px')
              ),
              'textarea' => array
              (
                'label'              => 'textarea',
                'default'            => 'Bla',
                'inputType'          => 'textarea',
                'eval'               => array('style'=>'width:50px')
              ),
              'select' => array
              (
                'label'              => 'select',
                'default'            => 'b',
                'inputType'          => 'select',
                'options'            => array('s' => 'Sidney', 'b' => 'Bristol'),
                'eval'               => array('includeBlankOption' => true)
              ),
              'checkbox' => array
              (
                'label'              => 'checkbox',
                'default'            => '1',
                'inputType'          => 'checkbox',
                'eval'               => array('style'=>'width:80px')
              ),
              'checkboxWizard' => array
              (
                'label'              => 'checkboxWizard',
                'default'            => 'b',
                'inputType'          => 'checkboxWizard',
                'options'            => array('s', 'b'),
                'reference'          => array('s' => 'Sidney', 'b' => 'Bristol'),
                'eval'               => array()
              ),
              'radio' => array
              (
                'label'              => 'radio',
                'default'            => 'b',
                'inputType'          => 'radio',
                'options'            => array('s' => 'Sidney', 'b' => 'Bristol'),
                'eval'               => array()
              ),
              'textStore' => array
              (
                'label'              => 'textStore',
                'default'            => 'Bla',
                'inputType'          => 'textStore',
                'eval'               => array()
              ),
              'pageTree' => array
              (
                'label'              => 'pageTree',
                'default'            => '104',
                'inputType'          => 'pageTree',
                'eval'               => array()
              ),
              'file' => array
              (
                'label'              => 'File',
            'default'            => 'files/dummy/galerie/abstrakt/dummy-1200x800-White.jpg',
                'inputType'          => 'fileTree',
                'eval'               => array('fieldType' => 'radio', 'files' => true, 'filesOnly' => true, 'multiple' => false, 'style'=>'width:150px')
              )
            ),
    ),
    'sql'       => "blob NULL"
);
zonky2 commented 3 years ago

Okay, ich hab alle durchgetestet, die meiner Meinung nach Sinn ergeben haben. Gibt es eigentlich irgendwo eine Liste welche Felder der MCW überhaupt unterstützt?

=> im Prinzip alle, die per DCA aufrufbar sind... siehe https://docs.contao.org/dev/reference/dca/fields/#reference bei inputType

ich mache im ersten Post mal eine Checkboxliste...

zonky2 commented 3 years ago

Default für fileTree: da muss m.E. das rein, wie es in der DB steht, d.h. die UUID(s) umgewandelt mit StringUtil::uuidToBin - bei mehreren Dateien das Array dann noch serialisiert ... siehe https://github.com/contao/core-bundle/blob/master/src/Resources/contao/widgets/FileTree.php

Total-Reality commented 3 years ago

Btw. wird das Contao Wiki eigentlich noch gepflegt oder bald abgeschaltet? Da steht ja auf der Startseite, dass die Seit zuletzt 2014 aktualisiert wurde? :(

https://de.contaowiki.org/MultiColumnWizard

Da steht "nospace" - "Ungetestet" - Ich hab es jetzt getestet und es funktioniert. Damit kann man ja verhindern, dass Leerzeichen eingegeben werden. 'nospace'=>true Auch "trailingSlash" funktioniert.

Weitere Erkenntnisse...

  1. tableWizard hab ich grad getestet, das funktioniert allgemein nicht mit MCW. Zum einen wird das Backend Layout komplett zerschossen und zum zweiten werden die getätigten Angaben nicht gespeichert. Daher stellt sich hier auch nicht die Frage, ob "default" funktioniert.

  2. inputUnit mit default funktioniert. Hab ich gerade getestet.

                    'inputUnit' => array
                    (
                        'label'                         => 'inputUnit',
            'default'            => array('value' => '13', 'unit' => 'kg'),
                        'inputType'                 => 'inputUnit',
                        'options'                       => array('l','kg'),
                        'eval'                          => array('includeBlankOption' => true, 'rgxp'=>'digit')
                    ),
  1. imageSize funktioniert ebenfalls
                    'imageSize' => array
                    (
                        'label'                         => 'imageSize',
                        'default'                       => array(400, 300, 'right_top'),
                        'inputType'                 => 'imageSize',
                        'reference'                 => &$GLOBALS['TL_LANG']['MSC'],
                        'eval'                          => array('rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true, 'tl_class'=>'w50'),
                        'options_callback' => static function ()
                        {
                            return Contao\System::getContainer()->get('contao.image.image_sizes')->getOptionsForUser(Contao\BackendUser::getInstance());
                        }
                    ),
  1. Default für fileTree: da muss m.E. das rein, wie es in der DB steht, d.h. die UUID(s) umgewandelt mit StringUtil::uuidToBin - bei mehreren Dateien das Array dann noch serialisiert ... siehe https://github.com/contao/core-bundle/blob/master/src/Resources/contao/widgets/FileTree.php

Danke für den Tip! Hab es gerade getestet mit dem default im MCW. Und es funktioniert ebenso... ist ja super, dass das geht

zonky2 commented 3 years ago

Danke für den Tipp! Hab es gerade getestet mit dem default im MCW. Und es funktioniert ebenso... ist ja super, dass das geht

was genau hast Du eingetragen?

Total-Reality commented 3 years ago

Einfach die uuid aus der Dateiverwaltung (Info Icon), z.B. dd8a031e-54da-11eb-8ca8-001a4a05040a

zonky2 commented 3 years ago

muss man nicht als Bin umwandeln?

Total-Reality commented 3 years ago

Bei einer Einzeldatei zumindest nicht. Mehrfach-Auswahl hab ich jetzt nicht ausprobiert.

              'file' => array
              (
                'label'              => 'File',
            'default'            => 'dd8a031e-54da-11eb-8ca8-001a4a05040a',
                'inputType'          => 'fileTree',
                'eval'               => array('fieldType' => 'radio', 'files' => true, 'filesOnly' => true, 'multiple' => false, 'style'=>'width:150px')
              )
Total-Reality commented 3 years ago

Ich hab jetzt noch listWizard und moduleWizard testweise genutzt. Beides wird - ebenso wie tableWizard (wie ich zuvor erwähnt hatte), nicht durch den MCW gespeichert. Von daher ist ein Einsatz von "default" sowieso sinnlos ^^ Diese 3 Dinge sollten gestrichen werden.

listWizard wäre schon sinnvoll, aber das hat dann nichts mehr mit diesem Thema hier zu tun. Das sollte dann erst mal grundsätzlich speicherbar sein. Erst danach ergibt ein Test des "default" Themas diesbezüglich Sinn.

moduleWizard ist darüber hinaus unvollständig und total unlogisch, um es hier einzusetzen. Das wird beim Core lediglich hier eingesetzt: https://github.com/contao/core/blob/303023b5f0b92de97437ce4fb656cdd067c207ed/system/modules/core/dca/tl_layout.php#L295

Ich schlussfolgere daraus, dass auch der Einsatz von sectionWizard (Used for defining sections in the page layout) absolut sinnfrei ist :)

'listWizard' => array
(
  'label'              => 'listWizard',
  'inputType'          => 'listWizard',
  'eval'               => array('allowHtml'=>true, 'multiple'=>true),
),
'modules' => array
(
  'label'              => &$GLOBALS['TL_LANG']['tl_layout']['modules'],
  'default'            => array(array('mod'=>0, 'col'=>'main', 'enable'=>1)),
  'exclude'            => true,
  'inputType'          => 'moduleWizard',
  'eval'               => array('multiple'=>true)
),
'tableWizard' => array
(
  'label'              => 'tableWizard',
  'inputType'          => 'tableWizard'
),
zonky2 commented 3 years ago

o.k. - in Liste geändert

Total-Reality commented 3 years ago

Was machen wir mit listWizard und tableWizard? Neues Ticket aufmachen, damit die Funktionalität an sich erst mal ermöglicht wird?

zonky2 commented 3 years ago

neue Tickets

Total-Reality commented 3 years ago

Weitere Tests... Aber default hab ich jeweils noch nicht ausprobiert.

  1. keyValueWizard = Wird nicht durch den MCW gespeichert und ergibt auch keinen Sinn, wozu brauch ich an dieser Stelle Schlüssel und Wert??? Das wird irgendwie im Theme und in den Stylesheets für globale Variablenersetzungen verwendet.

  2. chmod = Wird im MCW gespeichert, aber der Einsatzzweck für MCW erschließt sich mir nicht wirklich. Das steuert die Zugriffsrechte für Seiten und Artikel.

  3. optionWizard = Wird nicht durch den MCW gespeichert und ergibt auch nur geringfügig Sinn. Wofür braucht man so etwas? Das Ding ist ja quasi "MCW light". Das sind die Optionen, die man aus dem Formulargenerator kennt bei Checkbox Menü und Select.

  4. radioTable = Wird im MCW gespeichert, könnte einigermaßen sinnvoll sein. Mir fällt gerade kein sinnvoller Einsatzweck ein, aber damit kann man z.B. wie beim Inhaltselement Text die Bildausrichtung bestimmen.

  5. timePeriod = Wird im MCW gespeichert, der Sinn bzw. Vorteil gegenüber inputUnit erschließt sich mir nicht. Das wird glaube ich bei wiederholenden Events in Cotao eingesetzt.

'keyValueWizard' => array
(
    'inputType'               => 'keyValueWizard',
),
'chmod' => array
(
    'inputType'               => 'chmod',
),
'optionWizard' => array
(
    'inputType'               => 'optionWizard',
),
'radioTable' => array
(
    'exclude'                 => true,
    'inputType'               => 'radioTable',
    'options'                 => array('above', 'left', 'right', 'below'),
    'eval'                    => array('cols'=>4, 'submitOnChange'=>true),
    'reference'               => &$GLOBALS['TL_LANG']['MSC']
),
'timePeriod' => array
(
  'inputType'               => 'timePeriod',
  'inputType' => 'timePeriod',
  'options'   => ['seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years'],
  'reference' => &$GLOBALS['TL_LANG']['tl_calendar_events']['subscription_timeRef'],
  'eval'      => ['rgxp' => 'natural', 'minval' => 1, 'tl_class' => 'w50']
),
zonky2 commented 3 years ago

chmod und keyValueWizard aus Liste verschoben

Total-Reality commented 3 years ago

Folgende inputTypes funktionieren ebenso mit default... damit sind wir dann so gut wie durch:

                    'trbl' => array
                    (
                        'inputType'               => 'trbl',
            'default'                                   => array('top' => '2'),
                    ),
zonky2 commented 3 years ago

mit trbl dütftest Du recht haben...

Picker: z.B.

                'mcw_textfp'   => [
                    'label'     => ['mcw_textfp'],
                    'exclude'   => true,
                    'inputType' => 'text',
                    'eval'      => [
                        'style'          => 'width:40 % ',
                        'decodeEntities' => true,
                        'maxlength'      => 255,
                        'fieldType'      => 'checkbox',
                        'filesOnly'      => false,
                        /*'dcaPicker' => ['providers' => ['filePicker']],*/
                        'dcaPicker'      => ['providers' => ['pagePicker']],
                        /*'fieldType'=>'checkbox',*/
                        /*'filesOnly'=>true,*/

                    ],
                ],
Total-Reality commented 3 years ago

Danke. Das ist doch aber nicht inputType => picker?! Wenn ich als inputType = picker wähle, dann knallt das ganze BE weg. "Internal Server Error - The table name must not be empty"

Weder die Übergabe von relation, noch von foreignKey etc. funktioniert. Allerdings hab ich es innerhalb des MCW getestet. Vielleicht funktioniert es ja außerhalb?

Wenn ich z.B. picker2 eintragen, dann funktioniert das BE weiterhin. Es muss also mehr dahinter stecken.

Btw. warum schreibst du eigentlich exclude als Attribut rein? Greift das überhaupt beim MCW?

Hier noch die Angabe für tableWizard: 'default' => array(array('Zelle A1', 'Zelle A2'), array('Zelle B1', 'Zelle B2')),

Bei dem von dir genannten picker muss man ein Insert Tag übergeben, z.B. 'default' => '{{link_url::3}}', für Seite mit der ID 3

Dieses funktioniert also ebenso. Damit ist das default Thema eig. abgeschlossen, aber das mit dem picker ist halt leider noch unklar. Wobei ich mir nicht vorstellen kann, dass dort default nicht geht.

Total-Reality commented 3 years ago

@zonky2 tableWizard kannst du abhaken, Siehe mein Beitrag vom 19. Januar.

Nochmal zum picker: Ich weiß nicht, ob man das Thema deswegen offen lassen muss, da doch irgendwie noch nicht mal jemand ne Ahnung hat wie man das allgemein in Contao (ohne MCW) verwenden kann? Kann ja nicht sein, dass ihr eine Dokumentation aufbauen müsst, die Contao selbst noch nicht mal bietet :D Auch die default Geschichte allgemein geht schon deutlich über das Contao Handbuch hinaus.

zonky2 commented 3 years ago

auf Slack gabs zum Picker das Beispiel

'news' => [
        'inputType' => 'picker',
        'relation' => ['type' => 'hasOne', 'load' => 'eager', 'table' => 'tl_news'],
        // ...
    ],

k.A. ob da überhaut ein default vorgesehen ist