I've been using FormSave (
http://modx.com/extras/package/formsave) for several sites now and really love it. As you know, it serves to save form (FormIt form) data in the db for later retrieval.
Now, I've recently discovered Formz (
http://modx.com/extras/package/formz), which I'm liking a lot. So far, I've only experimented with it outside of a paying-client setting, but I like it. As you may know, Formz allows a code-challenged end user to quickly create and publish forms on their site at will. Really cool.
Kudos to both sets of authors, by the way.
However, I think it would be just ducky to be able to meld the two systems, so that the site owner could get saved data from forms they created. I'm wondering how to go about accomplishing that.
Things I've noticed:
1. In a FormIt only form setup, the form code (which utilizes the FormSave hook) looks something like this:
[[!FormIt?
&hooks=`spam,FormSave,email,emailUser,redirect`
&emailSubject=`Submission from The XXXX Contact Form`
&emailTpl=`EmailChunk`
&emailTo=`[email protected]`
&redirectTo=`1`
&fsFormTopic=`Contact`
&fsFormFields=`firstName,lastName,email,telephone,street,cityTown,state,zipcode,country,text`
&validate=`firstName:required,
lastName:required,
telephone:required,
email:required,`
]]
[[!+fi.error.error_message:notempty=`
<p>[[!+fi.error.error_message]]</p>
`]][[!+fi.error.rampart]
...the rest of the form code...
]
2. In a chunk that comes along with Formz called formtpl.chunk.tpl (core > components > formz > elements > chunks > formtpl.chunk.tpl) there is code that looks like this:
[[!FormIt?
&hooks=`[[+action]]`
&excludeFields=`submit[[+id]]`
&submitVar=`submit[[+id]]`
&formid=`[[+id]]` [[- "Form ID"]]
&store=`1`
&storeTime=`900`
&successMessage=`<p>[[+success_message]]</p>`
&emailTo=`[[+email:default=``]]`
[[+validation:notempty=`&validate=`[[+validation]]``]]
[[+validationText:notempty=`[[+validationText]]`]]
]]
[[!+fi.successMessage]]
[[!+fi.validation_error_message]]
<form class="form [[+identifier]]" action="" method="post">
<fieldset>
[[+fields]]
</fieldset>
<div class="actions">
<input type="submit" name="submit[[+id]]" value="[[+action_button:default=`Submit`]]" class="btn primary" />
</div>
</form>
...which looks similar to the first bit of code.
So, what I tried was melding the two by changing the Formz tpl code to look like this:
[[!FormIt?
&hooks=`FormSave,[[+action]]`
&excludeFields=`submit[[+id]]`
&submitVar=`submit[[+id]]`
&formid=`[[+id]]` [[- "Form ID"]]
&store=`1`
&storeTime=`900`
&fsFormTopic=`Misc`
&fsFormFields=`[[+fields]]`
&successMessage=`<p>[[+success_message]]</p>`
&emailTo=`[[+email:default=``]]`
[[+validation:notempty=`&validate=`[[+validation]]``]]
[[+validationText:notempty=`[[+validationText]]`]]
]]
[[!+fi.successMessage]]
[[!+fi.validation_error_message]]
<form class="form [[+identifier]]" action="" method="post">
<fieldset>
[[+fields]]
</fieldset>
<div class="actions">
<input type="submit" name="submit[[+id]]" value="[[+action_button:default=`Submit`]]" class="btn primary" />
</div>
</form>
The changes involve adding the FormSave hook to the top of the code, as well as this bit:
&fsFormTopic=`Misc`
&fsFormFields=`[[+fields]]`
...but that doesn't work. The form still works okay as it did without the FormSave part, but there's still no data being saved in the db.
I'm suspecting something to do with the
...part because the original (non-Formz form) declares all the fields to be saved as a list (Array? Would that be the proper term?), with commas as delimiters. But, I'm not sure.
Can any of you chime in here? I appreciate it in advance.
Install running on MODx Revolution 2.2.2.
[ed. note: waizen last edited this post 14 years ago.]