I’ll see if I can whip up another example using events but I’ll probably do that in the documentation wiki.
However, thinking about your problem again and I see no reason why you can’t use a snippet (or a modx tag) directly in the form template chunk. It depends on where you place it. For example if you have a snippet called insertEmail:
and you add this to the form template chunk
email: <input name="email" type="text" value="[[insertEmail]]" eform="Email::1:"/>
The
first time the form is displayed the email field will be filled by the snippet. In this case thi sonly works the first time the form is displayed because when the form is posted eForm will parse the form and use the posted value instead.
It all depends where you place the snippet call in the form. If it is inside <input>, <textarea> ,<select> or <option> tags then chances are that certain things get stripped by eForm when the form is posted. Otherwise your snippets should just work...
Here’s another example where a snippet is used to generate option tags:
Edit: This is actually a bad example!!!
Because the snippet is not evaluated until after eForm has finished, eForm will not be able to parse the inserted tags and when posting the form it will not see or not validate the values! To insert extra form elements you need to use the eFormOnBeforeParse event. Try this example and you’ll see eForm throws an error when the form is posted.
<?php
# insertOptionTags example snippet
$limit = isset($limit)?$limit:3;
$output = '';
for($i=0;$i<$limit;$i++){
$output .= '<option value="'.$i.'">option '.$i.'</option>';
}
return $output;
?>
And here’s where it is used in a form.
<select name="someSelection" eform="Selection Example::1">
[[extraOptions? ? &limit=`6`]]
</select>
By the way, you can also use modx tags in a form template. For instance:
<input type="submit" name="submit" value="Send this to [(site_name)] "/>
Edit: as promised I’ve added version 1.4.1 to the repository. See
this post for changes and a link to teh rpository