splitbrain / dokuwiki-plugin-data

Add and query structured data in your DokuWiki
http://www.dokuwiki.org/plugin:data
GNU General Public License v2.0
50 stars 34 forks source link

Multiple values with type aliases broken #231

Closed annda closed 2 years ago

annda commented 2 years ago

If type aliases are used together with a multi field and edit_content_only is set, we trigger an exception because \dokuwiki\Form\DropdownElement does not support multiple values yet (see https://github.com/splitbrain/dokuwiki/pull/3721).

Related to #228 and #229

@Juergen-aus-Zuendorf Thanks for reporting, I am working on the problem.

RaphaelWimmer commented 2 years ago

FWIW, @splitbrain's patch does not really fix the problem (at least in my case). While the following exception is no longer thrown,

InvalidArgumentException: Sorry, the dropdown element does not support the "multiple" attribute

the form fields are of the wrong type and show the wrong information.

In our thesis database, we have a few type aliases to support dropdown selections:

---- dataentry StudentischeArbeit ----
Thema                                  : Developing a Minimal Working Example # 
Art_thesistypes                        : BA # 
BetreuerIn_thesisadvisor               : Max Mustermann # 
BearbeiterIn                           : John Doe # 
ErstgutachterIn_thesisprofessor        : Prof1 # 
ZweitgutachterIn_secondthesisprofessor : Prof2 # 
Status_thesisstate                     : in Bearbeitung # 
----

This correctly renders both in Hogfather and in Igor. image

However, when editing the form via the special data edit button, fields are filled with wrong data:

image

Apparently, every select field remains a text field and is filled with the content of the previous normal text field.

Generated HTML:

<div class="page">

<p>
Bearbeiten Sie den <a href="[https://www.dokuwiki.org/plugin%3Adata](view-source:https://www.dokuwiki.org/plugin%3Adata)" class="interwiki iw_doku" title="https://www.dokuwiki.org/plugin%3Adata">Data-Eintrag</a> und klicken danach auf <code>Speichern</code>. Bitte verändern Sie die Daten nur, wenn Sie sie <strong>verbessern</strong> können.
</p>
<script>/*<![CDATA[*/textChanged = false/*!]]>*/</script><div class="editBox" role="application"><div class="toolbar group"><div id="tool__bar" class="tool__bar"></div></div><div id="draft__status" class="draft__status"></div><form id="dw__editform" action="[/playground/formtest](view-source:https://wiki.mi.ur.de/playground/formtest)" method="post" accept-charset="utf-8" class="doku_form"><input type="hidden" name="sectok" value="10bfb73e0a1ca24a2a9129b2d0114ccd" /><input type="hidden" name="id" value="playground:formtest" /><input type="hidden" name="rev" value="" /><input type="hidden" name="date" value="1663608348" /><input type="hidden" name="prefix" value="." /><input type="hidden" name="suffix" value="
" /><input type="hidden" name="changecheck" value="31c8246949a911ce7b14b738568f64a1" /><input type="hidden" name="data_edit[classes]" value="StudentischeArbeit" /><input type="hidden" name="data_edit[data][0][multi]" value="" /><input type="hidden" name="data_edit[data][0][comment]" value=" " /><input type="hidden" name="data_edit[data][0][type]" value="" /><input type="hidden" name="data_edit[data][0][title]" value="Thema" /><input type="hidden" name="data_edit[data][1][multi]" value="1" /><input type="hidden" name="data_edit[data][1][comment]" value=" " /><input type="hidden" name="data_edit[data][1][type]" value="thesistype" /><input type="hidden" name="data_edit[data][1][title]" value="Art" /><input type="hidden" name="data_edit[data][2][multi]" value="" /><input type="hidden" name="data_edit[data][2][comment]" value=" " /><input type="hidden" name="data_edit[data][2][type]" value="thesisadvisor" /><input type="hidden" name="data_edit[data][2][title]" value="BetreuerIn" /><input type="hidden" name="data_edit[data][3][multi]" value="" /><input type="hidden" name="data_edit[data][3][comment]" value=" " /><input type="hidden" name="data_edit[data][3][type]" value="" /><input type="hidden" name="data_edit[data][3][title]" value="BearbeiterIn" /><input type="hidden" name="data_edit[data][4][multi]" value="" /><input type="hidden" name="data_edit[data][4][comment]" value=" " /><input type="hidden" name="data_edit[data][4][type]" value="thesisprofessor" /><input type="hidden" name="data_edit[data][4][title]" value="ErstgutachterIn" /><input type="hidden" name="data_edit[data][5][multi]" value="" /><input type="hidden" name="data_edit[data][5][comment]" value=" " /><input type="hidden" name="data_edit[data][5][type]" value="secondthesisprofessor" /><input type="hidden" name="data_edit[data][5][title]" value="ZweitgutachterIn" /><input type="hidden" name="data_edit[data][6][multi]" value="" /><input type="hidden" name="data_edit[data][6][comment]" value=" " /><input type="hidden" name="data_edit[data][6][type]" value="thesisstate" /><input type="hidden" name="data_edit[data][6][title]" value="Status" /><input type="hidden" name="target" value="plugin_data" /><input type="hidden" name="hid" value="" /><fieldset class="plugin__data">
<legend>Data-Entry</legend><table class="edit_content_only"><tr><th class="title">Titel</th><th class="value">Wert</th><th class="comment">Kommentar</th></tr><tr><td class="title">Thema:</td><td class="value"><label class="data_type_ data_type_">
<span>Thema</span>
<input name="data_edit[data][0][value]" type="text" value="Developing a Minimal Working Example" class="data_type_ data_type_" />
</label></td><td class="comment"><span title=" "> </span></td></tr><tr><td class="title">Art:</td><td class="value"><label class="data_type_ data_type_">
<span>Thema</span>
<input name="data_edit[data][0][value]" type="text" value="Developing a Minimal Working Example" class="data_type_ data_type_" />
</label></td><td class="comment"><span title=" "> </span></td></tr><tr><td class="title">BetreuerIn:</td><td class="value"><label class="data_type_thesisadvisor data_type_tag">
<span>BetreuerIn</span>
<input name="data_edit[data][2][value]" type="text" value="Max Mustermann" class="data_type_thesisadvisor data_type_tag" />
</label></td><td class="comment"><span title=" "> </span></td></tr><tr><td class="title">BearbeiterIn:</td><td class="value"><label class="data_type_ data_type_">
<span>BearbeiterIn</span>
<input name="data_edit[data][3][value]" type="text" value="John Doe" class="data_type_ data_type_" />
</label></td><td class="comment"><span title=" "> </span></td></tr><tr><td class="title">ErstgutachterIn:</td><td class="value"><label class="data_type_ data_type_">
<span>BearbeiterIn</span>
<input name="data_edit[data][3][value]" type="text" value="John Doe" class="data_type_ data_type_" />
</label></td><td class="comment"><span title=" "> </span></td></tr><tr><td class="title">ZweitgutachterIn:</td><td class="value"><label class="data_type_ data_type_">
<span>BearbeiterIn</span>
<input name="data_edit[data][3][value]" type="text" value="John Doe" class="data_type_ data_type_" />
</label></td><td class="comment"><span title=" "> </span></td></tr><tr><td class="title">Status:</td><td class="value"><label class="data_type_ data_type_">
<span>BearbeiterIn</span>
<input name="data_edit[data][3][value]" type="text" value="John Doe" class="data_type_ data_type_" />
</label></td><td class="comment"><span title=" "> </span></td></tr></table></fieldset><div id="wiki__editbar" class="editBar"><div id="size__ctl"></div><div class="editButtons"><button name="do[save]" value="1" type="submit" accesskey="s" tabindex="4" id="edbtn__save">Speichern</button><button name="do[preview]" value="1" type="submit" accesskey="p" tabindex="5" id="edbtn__preview">Vorschau</button><button name="do[cancel]" value="1" type="submit" tabindex="6">Abbrechen</button></div><div class="summary"><label for="edit__summary" class="nowrap">
<span>Zusammenfassung</span>
<input name="summary" type="text" size="50" tabindex="2" id="edit__summary" class="edit" value="[Data-Entry] " />
</label> <label for="edit__minoredit" class="nowrap">
<input name="minor" type="checkbox" value="1" id="edit__minoredit" class="nowrap" />
<span>kleine Änderung</span>
</label></div></div><div class="license">Hinweis: Durch das Bearbeiten dieser Seite geben Sie Ihr Einverständnis, dass Ihr Inhalt unter der folgenden Lizenz veröffentlicht wird: <a href="[https://creativecommons.org/licenses/by/4.0/deed.de](view-source:https://creativecommons.org/licenses/by/4.0/deed.de)" rel="license" class="urlextern">CC Attribution 4.0 International</a></div></form></div>
<script type='text/javascript'>
syntaxhighlighterConfig = {
  autoLinks: true,
  gutter: true,
  htmlScript: false,
  tabSize: 4,
  smartTabs: true
}
</script>

        </div>

After saving the form, the fields with special type aliases are empty:

---- dataentry StudentischeArbeit ----
Thema                                  : Developing a Minimal Working Example
Art_thesistypes                        : 
BetreuerIn_thesisadvisor               : Max Mustermann
BearbeiterIn                           : John Doe
ErstgutachterIn_thesisprofessor        : 
ZweitgutachterIn_secondthesisprofessor : 
Status_thesisstate                     : 
----

Any suggestions?

splitbrain commented 2 years ago

I can confirm @RaphaelWimmer's report. Type aliases are not shown as Dropdowns, but instead a text input of the previous element is shown.