b03tz / FormSave

FormSave is a FormIt hook that allows you to save forms to the database and export them to a variety of formats.
16 stars 17 forks source link

store in DB-table and disable email #11

Closed myradon closed 11 years ago

myradon commented 11 years ago

Got a question concerning storing fields on the MODx-database. I can't find in the documentation how to save to DB. I also like to disable sending an email.

I would like to store mailadresses in the database for submitting to a newsletter so we don't need an email. How could i accomplish this?

exside commented 11 years ago

First: I don't think this qualifies as an issue here on github =)...such questions should be posted in the forums in my opinion.

Second: If you read the rtfm for formit, you would see that there is no hook for saving stuff into a db, so that is actually not an implemented feature (natively) BUT there is a way and it's called FormSave which is an additional hook for formit and can be found in the Package Manager and the docs here: http://rtfm.modx.com/display/ADDON/FormSave

Edit: LOL, thought I was on the formit github page, actually you already found the solution...that's FormSave's main purpose: Store Formit-Data in database table =)...for doc, see link below

Third: If you don't want to send an email, just leave the email hook away, then nothing gets sent =)

myradon commented 11 years ago

@exside thanx for responding. Formsave docs stated issues request go to github so I did.

I thought FormSave could also save in the DB that's why I want to use Formsave because I read the parameter fsFormPublish=1 Whether or not the form should have published "1" in the database. Currently unused.

I'll try your third suggestion.

myradon commented 11 years ago

Okay I see within the DB it gets stored in the table modx_formsave_forms so how to retrieve that data by easy call/whatever?

Third suggestion works! Thanx

exside commented 11 years ago

FormSave does only save to db =) and fsFormPublish has nothing to do with if an email is sent or not...and as you stated, it's currently unused.

The point of retrieving data back somewhere is a completly other story. You can view the saved data in the manager under components > formsave, but to get it back in the frontend you would probably have to write your own snippet (which btw would be very interesting to have a look at if you do) and use xpdo for it. You could probably derive that script from resources like:

http://rtfm.modx.com/display/xPDO20/Retrieving+Objects http://rtfm.modx.com/display/xPDO20/xPDO.getObject http://forums.modx.com/thread/79316/querying-gallery-tables-with-xpdo http://forums.modx.com/thread/77194/solved-basic-xpdo-queries-need-help http://www.codesphp.com/php-category/php-facebook-modx-revolution-to-query-database-xpdo-api.html

but basically it should be possible with something like $formsaveitem = $modx->getObject('fsForm'); $formsavedata = json_decode($formsaveitem->get('data'));

this is totally out of the blue and untested, but that's in my opinion how it should work because the formsave table is an xpdo object (maybe also try $modx->getColletion or so...)