[[FormIt? &hooks=`email,redirect` &emailTpl=`myEmailChunk` &emailTo=`[email protected]` &redirectTo=`123` ]] <h2>Contact Form</h2> <p>[[+fi.error.message]]</p> <form action="[[~[[*id]]]]" method="post" class="form"> <input type="hidden" name="nospam:blank" value="" /> <label for="name">Name:[[+fi.error.name]]</label> <input type="text" name="name:required" id="name" value="[[+fi.name]]" /> <label for="email">Email:[[+fi.error.email]]</label> <input type="text" name="email:email:required" id="email" value="[[+fi.email]]" /> <label for="subject">Subject:[[+fi.error.subject]]</label> <input type="text" name="subject:required" id="subject" value="[[+fi.subject]]" /> <label for="text">Message:[[+fi.error.text]]</label> <textarea name="text:required:stripTags" id="text" cols="55" rows="7">[[+fi.text]]</textarea> <br class="clear" /> <div class="form-buttons"> <input type="submit" value="Send Contact Inquiry" /> </div> </form>
# <h2>Contact Form</h2> # # <p>[[+fi.error.message]]</p> # # <form action="[[~[[*id]]]]" method="post" class="form"> # <input type="hidden" name="nospam:blank" value="" /> # # <label for="name"> # Name: # <span class="error">[[+fi.error.name]]</span> # </label>
# <h2>Contact Form</h2> # # [[+fi.error?name=`message` &tag=`p`]] # # <form action="[[~[[*id]]]]" method="post" class="form"> # <input type="hidden" name="nospam:blank" value="" /> # # <label for="name"> # Name: # [[+fi.error?name=`name`]] # </label> # <label for="email"> # Email: # [[+fi.error?name=`email` &class=`myError`]] # </label> # <input type="text" name="email:email:required" id="email" value="[[+fi.email]]" />
# <h2>Contact Form</h2> # # <p class="error">Some errors occured</p> # # <form action="[[~[[*id]]]]" method="post" class="form"> # <input type="hidden" name="nospam:blank" value="" /> # # <label for="name"> # Name: # <span class="error">Name is missing</span> # </label> # <label for="email"> # Email: # <span class="MyError">E-Mail is not valid</span> # </label> # <input type="text" name="email:email:required" id="email" value="[[+fi.email]]" />
Howabout a &errorTpl parameter than you can wrap error messages in? That would be better than putting HTML into the snippet code. (And properties cant have properties on them, as in your example.)
Sounds great!
One suggestion:
How about an error message function where (custom) HTML tags and classes are only displayed if an error occurs. Because validating fails if there are empty (and unnecessary) tags. Like:
span and class "error" are default, if you want something other, you can put it in the error placeholder as parameter.
By ’event’, what do you mean? It has ’hooks’, which act as events - you can attach snippets to fire as hooks after the form is validated. You can also make snippets be validators, too: http://svn.modxcms.com/docs/display/ADDON/FormIt
does it have the event that eForm has?
and do I mis the report chunk?Report chunk? Can you elaborate?
And properties cant have properties on them, as in your example.
All tags - no longer just Snippets - now accept properties, as well, that can be used. For example, let’s say we had a Chunk named ’Hello’ with the content: