splitbrain / dokuwiki-plugin-bureaucracy

Create forms and generate pages or emails from them
http://www.dokuwiki.org/plugin:bureaucracy
GNU General Public License v2.0
43 stars 46 forks source link

Troubles displaying data from conditional / hidden fieldsets #201

Open Cmbnf opened 7 years ago

Cmbnf commented 7 years ago

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 ?

LouisOuellet commented 6 years ago

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

vincowl commented 5 years ago

@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 ?

LouisOuellet commented 5 years ago

@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.

vincowl commented 5 years ago

@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 @

duenni commented 5 years ago

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