简体   繁体   中英

Modx formz does not keep the submitted values neither its error messages

I want to use the gumbyframework for my forms with the modx addon formz. To do so, I had to create my own chunks which are below. I "think" that I have all the elements needed, and the chunks are used so I can't see why this is not working properly. The main error message is displayed though.

I also get this error message, but I don't know if it is related to formz.

[2014-03-03 19:32:47] (ERROR @ /example/index.php) `[[+id]]` is not a valid integer and may not be passed to makeUrl()

formTpl

[[!FormIt?
&hooks=`[[+action]][[+hooks:notempty=`,[[+hooks]]`]]`
&tpl=`emailTpl`
&excludeFields=`submit[[+id]]`
&submitVar=`submit[[+id]]`
&formid=`[[+id]]` [[- "Form ID"]]
&store=`1`
&storeTime=`900`
&successMessage=`<p>[[+success_message]]</p>`
&emailTo=`[[+email:default=``]]`
[[+properties]]
[[+validation:notempty=`&validate=`[[+validation]]``]]
[[+validationText:notempty=`[[+validationText]]`]]
]]

[[!+fi.successMessage]]
[[!+fi.validation_error_message]]

<form id="form[[+id]]" class="form [[+identifier]]" action="" method="post">
<fieldset>
    [[+fields]]
</fieldset>

<div class="actions row">
    <div class="form__field__submit columns ten push_two">
        <input type="hidden" name="submit[[+id]]"  value=" [[+action_button:default=`Submit`]]"/>
        <a class="submit" type="submit" name="submit[[+id]]" class="btn primary" href="javascript:document.getElementById('form[[+id]]').submit();">[[+action_button:default=`Submit`]]</a>
    </div>
</div>

fieldTpl

[[!field? &type=`[[+type]]` &name=`[[+id]]` &label=`[[+label]]` &req=`[[+required]]` [[+type:eq=`checkbox`:then=`&array=`1``]] &options=`[[+values]]` &default_value=`[[+default]]` &tpl=`formz__field--gumby` &outer_tpl=`formz__wrap--gumby`]]

field wrap

<!-- default -->
<div class="[[+outer_class]] row" id="[[+name]]_wrap">
<div class="form__field__label columns two">
<label for="[[+name]]" title="[[+name:replace=`_== `:ucwords]]">[[+label:default=`[[+name:replace=`_== `:ucwords]]`]][[+req:notempty=` *`]]</label>
</div>
<div class="form__field__input columns ten field">
[[+inner_html]]
[[+note:notempty=`<span class="[[+note_class:default=`note`]]"><em>[[+note]]</em></span>`]]
[[+error:notempty=`<span class="[[+error_class]]">[[+error]]</span>`]]
</div>
</div>
<!-- default -->

<!-- select -->
<div class="[[+outer_class]] row form__row--half_margin_bottom" id="[[+name]]_wrap">
<div class="form__field__label columns two">
<label for="[[+name]]" title="[[+name:replace=`_== `:ucwords]]">[[+label:default=`[[+name:replace=`_== `:ucwords]]`]][[+req:notempty=` *`]]</label>
</div>
[[+inner_html]]
[[+note:notempty=`<span class="[[+note_class:default=`note`]]"><em>[[+note]]</em></span>`]]
[[+error:notempty=`<span class="[[+error_class]]">[[+error]]</span>`]]
</div>
</div>
<!-- select -->

<!-- radio -->
<div class="[[+outer_class]] row form__row--half_height" id="[[+name]]_wrap">
<div class="form__field__label columns two">
<label for="[[+name]]" title="[[+name:replace=`_== `:ucwords]]">[[+label:default=`[[+name:replace=`_== `:ucwords]]`]][[+req:notempty=` *`]]</label>
</div>
[[+inner_html]]
[[+note:notempty=`<span class="[[+note_class:default=`note`]]"><em>[[+note]]</em></span>`]]
[[+error:notempty=`<span class="[[+error_class]]">[[+error]]</span>`]]
</div>
</div>
<!-- radio -->

<!-- checkbox -->
<div class="[[+outer_class]] row form__row--half_height" id="[[+name]]_wrap">
<div class="form__field__label columns two">
<label for="[[+name]]" title="[[+name:replace=`_== `:ucwords]]">[[+label:default=`[[+name:replace=`_== `:ucwords]]`]][[+req:notempty=` *`]]</label>
</div>
[[+inner_html]]
[[+note:notempty=`<span class="[[+note_class:default=`note`]]"><em>[[+note]]</em></span>`]]
[[+error:notempty=`<span class="[[+error_class]]">[[+error]]</span>`]]
</div>
</div>
<!-- checkbox -->

field type

<!-- default -->
    <input type="[[+type]]" name="[[+name]]" id="[[+key]]" value="[[+current_value:default=`[[+default]]`]]" class="[[+type]] [[+class]][[+error_class]] text" size="[[+size:default=`40`]]" placeholder="[[+default]]" />
<!-- 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:default=`[[+default]]`]]" />
<!-- hidden -->

<!-- textarea -->
    <textarea id="[[+key]]" class="[[+type]] [[+class]][[+error_class]]" name="[[+name]]">[[+current_value:default=`[[+default]]`]]</textarea>
<!-- textarea -->

<!-- checkbox -->
<div class="form__field__input field columns ten [[+error_class]]">
    <input name="[[+name]][[+array:notempty=`[]`]]" type="hidden" value="" />
    [[+options_html]]
<!-- checkbox -->

<!-- radio -->
<div class="form__field__input field columns ten [[+error_class]]">
    <input type="hidden" name="[[+name]]" value="" />
    [[+options_html]]
<!-- radio -->

<!-- select -->
<div class="form__field__input field columns ten [[+class]][[+error_class]]">
    <input type="hidden" name="[[+name]][[+array:notempty=`[]`]]" value="" />
    <div class="picker">
        <select name="[[+name]][[+array:notempty=`[]`]]" id="[[+key]]" class="[[+class]] select"[[+multiple:notempty=` multiple="multiple"`]][[+title:notempty=` title="[[+title]]"`]]>
            [[+header:notempty=`<option value="[[+default]]">[[+header]]</option>`]]
            [[+options_html]]
        </select>
    </div>
<!-- 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 -->
<label for="[[+key]]" class="[[+type]]" id="label[[+key]]">
    <input name="[[+name]][[+array:notempty=`[]`]]" id="[[+key]]" value="[[+value]]" type="[[+type]]" />
    <span class="[[+type]]_icon"></span>
    [[+label]]
</label>
<!-- bool -->

I think either you are not explicitly submitting a field called "id" [name="id"] or the makeUrl function is trying to process this: &formid= [[+id]] [[- "Form ID"]], where it actually needs an integer.

also is formid actually a parameter for formit? [if it is are you sure it's not formID?]

I've had this issue, and I've resolved it by doing the following.

In my core/components/formitbuilder/chunks/fieldtypestpl.chunk.tpl file

I adjusted the value element to:

[[+fi.[[+name]]]]

This does removed the +default option. However it wasn't required for my usage anyway. Hope this helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM