Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Default" funktioniert nicht #83

Open
16 of 17 tasks
zonky2 opened this issue Jul 4, 2020 · 21 comments
Open
16 of 17 tasks

"Default" funktioniert nicht #83

zonky2 opened this issue Jul 4, 2020 · 21 comments
Assignees
Labels
dokumentation dokumentation
Milestone

Comments

@zonky2
Copy link
Contributor

zonky2 commented Jul 4, 2020

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

siehe menatwork/MultiColumnWizard#260

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

  • checkbox Checkbox: 'default' => '1',
  • checkboxWizard Checkbox Wizard: 'default' => '2', (Key des Options-Array-Items)
  • fileTree File tree: 'default' => 'dd8a031e-54da-11eb-8ca8-001a4a05040a' (UUID der Datei)
  • imageSize Two text fields with drop-down menu: 'default' => [400, 300, 'right_top'],
  • inputUnit Text field with small unit drop-down menu: 'default' => ['value' => '42', 'unit' => 'kg'], (unit-Wert aus Options-Array)
  • listWizard List wizard: 'default' => ['Listenpunkt 1', 'Listenpunkt 2']
  • optionWizard Option wizard: 'default' => [['value' => 'achtung', 'label' => 'Achtung'], ['value' => 'alarm', 'label' => 'Alarm']]
  • pageTree Page tree: 'default' => '42', (id der Seite)
  • picker General purpose picker
  • radio Radio button: 'default' => '2', (Key des Options-Array-Items)
  • radioTable Table with images and radio buttons: 'default' => 'right' (Key des Options-Array-Items)
  • select Drop-down menu: 'default' => '2', (Key des Options-Array-Items)
  • tableWizard Table wizard: 'default' => [['Zelle A1', 'Zelle A2'], ['Zelle B1', 'Zelle B2']]
  • text Text field: 'default' => 'Hallo Welt',
  • textarea Textarea: 'default' => 'Hallo Welt',
  • timePeriod Text field with drop-down menu: 'default' => ['value' => '13', 'unit' => 'days'] (unit-Wert aus Options-Array)
  • trbl Four text fields with a small unit drop-down menu: 'default' => ['top' => '2'] (keys = top, right, bottom, left)

Die Folgenden Widgets machen keinen Sinn:

  • chmod CHMOD table
  • keyValueWizard Key » Value wizard
  • metaWizard Used for setting meta information in the file manager
  • moduleWizard Module wizard
  • password Password field
  • sectionWizard Used for defining sections in the page layout
  • serpPreview Search Engine Result Preview (SERP) widget
  • textStore Text field that will not display its current value
@zonky2 zonky2 added the bug Something isn't working label Jul 4, 2020
@zonky2 zonky2 added this to the 3.4.5 milestone Jul 4, 2020
@zonky2 zonky2 modified the milestones: 3.4.5, 3.4.x Sep 9, 2020
@Total-Reality
Copy link

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

@zonky2
Copy link
Contributor Author

zonky2 commented Dec 5, 2020

dann bitte alle testen...

@Total-Reality
Copy link

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:

  • text
  • textarea
  • select
  • checkbox
  • checkboxWizard
  • radio
  • pageTree

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

  • textStore

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

  • password

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:

  • fileTree

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
Copy link
Contributor Author

zonky2 commented Jan 16, 2021

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
Copy link
Contributor Author

zonky2 commented Jan 16, 2021

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
Copy link

Total-Reality commented Jan 16, 2021

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
Copy link
Contributor Author

zonky2 commented Jan 16, 2021

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
Copy link

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

@zonky2
Copy link
Contributor Author

zonky2 commented Jan 16, 2021

muss man nicht als Bin umwandeln?

@Total-Reality
Copy link

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')
		      )

@zonky2 zonky2 added the dokumentation dokumentation label Jan 16, 2021
@Total-Reality
Copy link

Total-Reality commented Jan 16, 2021

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
Copy link
Contributor Author

zonky2 commented Jan 16, 2021

o.k. - in Liste geändert

@Total-Reality
Copy link

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

@zonky2
Copy link
Contributor Author

zonky2 commented Jan 16, 2021

neue Tickets

@Total-Reality
Copy link

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
Copy link
Contributor Author

zonky2 commented Jan 17, 2021

chmod und keyValueWizard aus Liste verschoben

@Total-Reality
Copy link

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

  • listWizard - 'default' => array('Listenpunkt 1', 'Listenpunkt 2'),
  • optionWizard - ''default' => array(array('value' => 'achtung', 'label' => 'Achtung'), array('value' => 'alarm', 'label' => 'Alarm')),
  • radioTable - 'default' => 'right', (Key des Options-Array-Items)
  • timePeriod - 'default' => array('value' => '13', 'unit' => 'days'), (unit-Wert aus Options-Array)
  • trbl - default Übergabe mittels array, keys = top, right, bottom, left*
  • picker - krieg ich grundsätzlich nicht zum laufen. Was muss man da im DCA einstellen???
  • Ergibt das Sinn trbl einzusetzen? Das ist doch das Teil aus den Stylesheets. Wird das sonst noch irgendwo benutzt?
    Wenn nein, fliegt das mit Contao 5 doch bestimmt sowieso aus dem System raus.
					'trbl' => array
					(
						'inputType'               => 'trbl',
            'default'									=> array('top' => '2'),
					),

@zonky2
Copy link
Contributor Author

zonky2 commented Jan 19, 2021

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
Copy link

Total-Reality commented Jan 19, 2021

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.

@zonky2 zonky2 removed the bug Something isn't working label Feb 24, 2021
@Total-Reality
Copy link

@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
Copy link
Contributor Author

zonky2 commented Mar 20, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dokumentation dokumentation
Projects
None yet
Development

No branches or pull requests

3 participants