Skip to content

Conversation

@lisps
Copy link
Collaborator

@lisps lisps commented Nov 2, 2016

when dependent fieldsets are used only the last field with the same name is taken.

@Klap-in @micgro42 can you have a look at it?

it is more or less used in mailaction to only get the correct fieldset. (https://github.com/splitbrain/dokuwiki-plugin-bureaucracy/blob/master/helper/actionmail.php#L105)

@Klap-in
Copy link
Collaborator

Klap-in commented Nov 2, 2016

Can you give an example (the syntax) of a form that is fixed by this? That is easier testing.

@lisps
Copy link
Collaborator Author

lisps commented Nov 2, 2016

<pagemod a>
  * @@var@@</pagemod>

<form>
select depends a|b|c
action pagemod _self a

fieldset Fieldset1 depends a 
Textbox  var =a

fieldset Fieldset2 depends b 
Textbox  var =b

fieldset Fieldset3 depends c 
Textbox  var =c 

Fieldset
submit
</form>

@Klap-in
Copy link
Collaborator

Klap-in commented Nov 2, 2016

Hmm, the fieldset field sets all its containing fields already to hidden by itself. So no logic is required later. I think checking if $field->hidden is true is already enough.

(This means that the mail action can be simplified as well, but that is not scope of this PR)

@lisps
Copy link
Collaborator Author

lisps commented Nov 3, 2016

sometimes its so easy 😉

@lisps lisps added the Bug label Nov 3, 2016
@Klap-in
Copy link
Collaborator

Klap-in commented Nov 3, 2016

Hehe, thanks! I will test it if I have some free time.

@Klap-in
Copy link
Collaborator

Klap-in commented Nov 5, 2016

This solution doesn't yet prepare always replacement pairs (label-value patterns) for each field, because fields are skipped for closed/hidden fieldsets. While the original situation assumes that for all fields always such a pattern pair was created. Even when no value is given, a replacement pattern is needed to replace the placeholder with the Default value for a placeholder like: @@labelname|Default value@@.

A solution could be to fill the $this->patterns[$label] and $this->values[$label] with patterns for empty values by calling in prepareFieldReplacements() prepareFieldReplacement() with $value=null And later on use the updated code to override patterns of fields which has a non-empty value.

syntax that let reproduce this situation:

<pagemod a>
  * @@var@@
  * @@secondvar|Default1@@
  * @@thirdvar|Default2@@</pagemod>

<form>
select depends a|b|c
action pagemod _self a
Textbox thirdvar =d !

fieldset Fieldset1 depends a 
Textbox  var =a

fieldset Fieldset2 depends b 
Textbox  var =b
Textbox secondvar =e

fieldset Fieldset3 depends c 
Textbox  var =c 

Fieldset
submit
</form>

lisps added 2 commits November 7, 2016 08:57
so default values can be used on replacement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants