I'm using Formz to let my clients build their own forms. They place it on a page by using the formz tv, like this:
This tag has to be uncached, otherwise the labels don't get saved in emails and in the DB (see
https://github.com/silentworks/formz/issues/46 )
But somewhere in the process the error placeholders don't get set anymore. When I submit a form with some required fields blank, the general error message does show (fi.validation_error_message), but the individual messages don't.
This is my FormTpl:
[[!FormIt?
&hooks=`[[+action]]`
&excludeFields=`submit[[+id]],op1,operator,op2,math`
&submitVar=`submit[[+id]]`
&formid=`[[+id]]` [[- "Form ID"]]
&store=`1`
&senderName=`Website`
&storeTime=`900`
&successMessage=`<p>[[+success_message]]</p>`
&emailTo=`[[+email:default=``]]`
&properties=`[[+properties]]`
[[+validationText:notempty=`[[+validationText]]`]]
&validationErrorMessage=`<div class="errors"><h2>Er zijn fouten in het formulier gevonden</h2> <p>Wil je de volgende velden controleren?</p><ul>[[+errors]]</ul></div>`
&validate=`
math:required:minValue=`5`:maxValue=`5`,
[[+validation]]`
&math.vTextRequired=`Beantwoord de rekensom met '5'`
&math.vTextMinValue=`Beantwoord de rekensom met '5'`
&math.vTextMaxValue=`Beantwoord de rekensom met '5'`
]]
<form class="formulier [[+identifier]]" action="[[~[[*id]]]]#formulier" method="post" id="formulier" role="form">
[[!+fi.successMessage:isnot=``:then=`<div class="success"><h2>Het formulier is verzonden!</h2>[[!+fi.successMessage]]</div>`:else=``]]
[[!+fi.validation_error_message]]
<fieldset>
[[+hooks:notempty=`<legend>[[+hooks]]</legend>`]]
[[+fields]]
<div class="form-field antispam [[!+fi.error.math:notempty=`fieldError`]]">
<label [[+fi.error.math:notempty=`class="error"`]] for="math">Hoeveel is 3 plus 2?<span class="formRequired">*</span> <span class="comment">(even checken of u geen robot bent)</span></label>
<input type="hidden" id="op1" name="op1" value="3" /> <input type="hidden" id="operator" name="operator" value="+" /> <input type="hidden" id="op2" name="op2" value="2" />
<input type="text" class="form-field [[+fi.error.math:notempty=`error`]] required math" name="math" id="math" value="[[+math]]" />
[[+fi.error.math:notempty=`<span class="error">Vul het antwoord op de som in</span>`]]
</div>
<div class="submit-container">
<input type="submit" name="submit[[+id]]" value="[[+action_button:default=`Versturen`]]" class="submit-button" />
</div>
</fieldset>
</form>
I did some debugging and found that in the file ffpfield.class.php (from FormitFastPack) there is a function getError that gets the FormIt placeholder for the error for each of the fields (if I understand correctly). This is the function:
$error = $this->modx->getPlaceholder($this->config['error_prefix'] . $this->config['name']);
When I use the formz tv cached, like: [[*form]], the placeholder is set and the function gets the error correctly. When I use the uncached version however, this function returns no error. In other words, the placeholder is not (yet?) set.
This probably has something todo with parsing order. I just don't know what I should to to fix it. I hope someone can help me with this! If this works, Formz + FormIt + FFP provide a great combination!
---
Revo 2.2.10
Formz 1.0.0 rc3
Formit 2.2.0
FormitFastPack 1.1.0