dokuwiki-plugin-bureaucracy icon indicating copy to clipboard operation
dokuwiki-plugin-bureaucracy copied to clipboard

Troubles displaying data from conditional / hidden fieldsets

Open Cmbnf opened this issue 7 years ago • 5 comments

I have some troubles displaying the data from conditional fieldsets.

I want to use the Bureaucracy plugin to create a new project, with various parameters.

Here is my code :

<form>
action   template template "projets:@@Project name@@:page"

fieldset ""
textbox  "Project name"
user  "Creator"
textbox  "Description"

fieldset  "Machines"
select  "Machine"  " |3D printer|Laser cutter|Plotter"

fieldset  "Materials"  "Machine"  "Laser cutter"
select  "Material"  " |wood 8mm|medium 3 mm|cardboard|leather"

fieldset  "Materials"  "Machine"  "3D printer"
select  "Material"  " |PLA|ABS"

fieldset  "Materials"  "Machine"  "Plotter"
select  "Material"  " |paper|vinyl"

submit  "Create page"
</form>
====== @@Project name@@ ======
  * Creator : [[:user:@@Creator@@]]
  * Creation date : %d/%m/%Y

===== Description =====

@@Description@@

===== Tools & materials =====

**Tools :** @@Machine@@

**Materials :** @@Material@@

When I create a new project with the form, the "Materials" section isn't displayed (I mean it remains @@Materials@@), unless the selected choice for "Machine" is the last one (so here "Plotter"). So if I chose "Laser cutter" or "3D printer" for the "Machine field", in the project the materials aren't displayed, just @@Materials@@).

How can I fix it ?

Cmbnf avatar Mar 20 '17 17:03 Cmbnf

Hi, I managed to get around this by using hidden fields and wiki text. But in my case, I was displaying a company address in textboxes. From my understanding, the problem is that when the page is being generated, it converts everything in html tags. And in html form, if you have multiple <input> with the same ID/name only the last one will be submitted. Thus you need to find a way to Identify them all with unique labels. Then you can display the results using @@Material1|@@@@Material2|@@@@Material3|Alternate Text@@

Otherwise, you might want to take a look at https://www.dokuwiki.org/plugin:data

Hope this helps

LouisOuellet avatar Oct 12 '17 00:10 LouisOuellet

@LouisOuellet I have troubles using your tip. For instance, if Material1 is filled with Foo, @@Material1|@@@@Material2|@@@@Material3|Alternate Text@@ renders FooAlternate Text. But if Material2 or Material3 is filled with Bar, @@Material1|@@@@Material2|@@@@Material3|Alternate Text@@ renders Bar Any idea to solve this ? Did you face this problem even if your post is old ?

vincowl avatar Feb 08 '19 14:02 vincowl

@vincowl it seems I made a typo back then xD. The logic goes as follow, @@Field1|Alt@@. Or if Field1 has something print its content otherwise print "Alt". Thus if you have multiple fields that replaces each others like in the example, you should nest them in each others trought the alternate text field. Therefore @@Material1|@@Material2|@@Material3|Alternate Text@@@@.

I'll see if I can test it tonight after work.

LouisOuellet avatar Feb 08 '19 18:02 LouisOuellet

@LouisOuellet unfortunately, it doesn't work here... Previous solution behaves like this : string is split in a @@Material1|@@ (alternate text empty), a Material2| fixed text and @@Material3|Alternate Text@@ sequence followed by 2 fixed @

vincowl avatar Feb 10 '19 16:02 vincowl

I think I had a similar problem. You could just create three templates -> a template for printer, laser and cutter and then choose it depending on the select field. This way you don't need to use the chaining logic @@Materialx|Alternative@@. Have a look at this #261

duenni avatar Feb 24 '19 00:02 duenni