yoleg / FormitFastPack

A flexible MODX Revolution extra that helps generate, template, and maintain HTML for forms and email reports.
https://websitezen.com/formitfastpack
8 stars 6 forks source link

Only last checkbox option rendered with fiGenerateReport #9

Closed Spheerys closed 8 years ago

Spheerys commented 8 years ago

Hi,

I have a checkbox option like this :

        [[!field? &type=`checkbox` &name=`languages` &label=`Languages` &default=`Français` &req=`1` &options=`Français||English||Español`]]

But on the Genetared Report, I have only the last ticked check box.

I want to have this kind of result, with all options checked :

Français, Español

What's going wrong ?

yoleg commented 8 years ago

Does adding &array=1 fix the problem? Do you have a custom fieldTypesTpl? @Spheerys

Spheerys commented 8 years ago

I have add the array parameter like this :

[[!field? &type=`checkbox` &name=`langues_souhaitées` &label=`Visites en langue étrangère` &default=`Français` &req=`1` &array=`1` &options=`Français||English||Español`]]

After, I did a test but this time, I have no result for this checkbox !

And yes, I have a custom fieldTypesTpl but I'm not sure I have modified it. It's looking like this :

<!-- default -->
  <input type="[[+type]]" name="[[+name]]" id="[[+key]]" value="[[+current_value]]" class="[[+type]] [[+class]][[+error_class]]" size="[[+size:default=`40`]]" />
<!-- default -->
<!-- file -->
  <input type="[[+type]]" name="[[+name]][[+array:notempty=`[]`]]" id="[[+key]]" class="[[+type]] [[+class]][[+error_class]]" />
<!-- file -->
<!-- hidden -->
  <input type="[[+type]]" name="[[+name]]" value="[[+current_value]]" />
<!-- hidden -->
<!-- textarea -->
  <textarea id="[[+key]]" class="[[+type]] [[+class]][[+error_class]]" name="[[+name]]">[[+current_value]]</textarea>
<!-- textarea -->
<!-- checkbox -->
<span class="boolWrap[[+error_class]]">
<input name="[[+name]][[+array:notempty=`[]`]]" type="hidden" value="" />
[[+options_html]]
</span>
<!-- checkbox -->
<!-- radio -->
<span class="boolWrap[[+error_class]]">
<input type="hidden" name="[[+name]]" value="" />
[[+options_html]]
</span>
<!-- radio -->
<!-- select -->
<span class="[[+class]][[+error_class]]">
<input type="hidden" name="[[+name]][[+array:notempty=`[]`]]" value="" />
<select name="[[+name]][[+array:notempty=`[]`]]" id="[[+key]]" class="[[+class]]"[[+multiple:notempty=` multiple="multiple"`]][[+title:notempty=` title="[[+title]]"`]]>
  [[+header:notempty=`<option value="[[+default_value]]">[[+header]]</option>`]]
  [[+options_html]]
</select>
</span>
<!-- select -->
<!-- static -->
<span class="static_field[[+error_class]]">[[!+[[+name]]]]</span>
<!-- static -->
<!-- submit -->
<input id="[[+key]]" class="button [[+type]] [[+class]]" name="[[+name]]" type="[[+type]]" value="[[+message:default=`Submit`]]" />
<input id="[[+name]]-clear" class="button [[+type]] [[+class]]" type="reset" value="[[+clear_message:default=`Clear Form`]]" />
<!-- submit -->
<!-- option --><option value="[[+value]]">[[+label]]</option><!-- option -->
<!-- bool -->
<span class="boolDiv [[+class]]">
<input type="[[+type]]" class="[[+type]]" value="[[+value]]" name="[[+name]][[+array:notempty=`[]`]]" id="[[+key]]"  /> 
<label for="[[+key]]" class="[[+type]]" id="label[[+key]]">[[+label]]</label></span><!-- bool -->
yoleg commented 8 years ago

Can you try using the fiProcessArrays in your FormIt hooks before the generate report hook? If that does not work, can you please also include the entire code for your form (including the FormIt call) and perhaps even a copy of the generated form HTML?

It might be easier if you create a test MODX install somewhere, reproduce the issue, and PM me manager access. Then I can take a look at it myself.

Spheerys commented 8 years ago

That's it ! After adding fiProcessArrays in the FormIt call, the array works ! Maybe should you add this to the documentation to avoid futures issues !

Thanks by the way :)

yoleg commented 8 years ago

@Spheerys Strange, I thought the latest version of FormIt now concatenated array values, which is why I downplayed fiProcessArrays in the docs. I'll add a section in for that to the fiGenerateReport doc.