I have noticed that when I have a form that does not submit via AJAX, the error message is displayed below the element after the page reloads.
However, when the page does get submitted via AJAX (eg. with the content plugin), the error message only appears in the tip box which can only be seen by hovering over the error icon.
Many of our users are missing this message so I have made a slight modification to replicate the same behaviour when submitting with AJAX.
In element.js I added the following line just before the break statement in the fabrikError case:
The resulting code looks like this:
Then, make sure the following code is in the template where you want the message to appear in the form when submitting via AJAX:
That's it. If the fabrikShowError class doesn't exist then everything continues to work as it does currently (no JS errors). It is now very easy to add the class wherever you want the error message to show.
I hope this can make it into Fabrik as it is backwards compatible and makes the AJAX submission consistent. I am open to suggestions on a better way to do this but this was the easiest way I could find to get the desired result.
Thanks for considering!
However, when the page does get submitted via AJAX (eg. with the content plugin), the error message only appears in the tip box which can only be seen by hovering over the error icon.
Many of our users are missing this message so I have made a slight modification to replicate the same behaviour when submitting with AJAX.
In element.js I added the following line just before the break statement in the fabrikError case:
HTML:
this.getContainer().getElements('.fabrikShowError').set('html', msg);
HTML:
case 'fabrikError':
a = new Element('a', {'href': '#', 'title': msg, 'events': {
'click': function (e) {
e.stop();
}
}}).adopt(this.alertImage);
errorElements[0].adopt(a);
Fabrik.tips.attach(a);
this.getContainer().getElements('.fabrikShowError').set('html', msg);
break;
HTML:
<div class="fabrikErrorMessage fabrikShowError">
<?php echo $element->error;?>
</div>
I hope this can make it into Fabrik as it is backwards compatible and makes the AJAX submission consistent. I am open to suggestions on a better way to do this but this was the easiest way I could find to get the desired result.
Thanks for considering!