listening/notification question

blindmime
@blindmime
10 years ago
772 posts
I have an Aparna-created module with a lengthy form. The user fills out parts of the form over the course of several sessions, submitting it at the end of each session. When the user is done with the form, there is a check box to indicate the form is complete. They check this and then submit.

Is there a way to be notified just when the form is submitted when that box is checked?
updated by @blindmime: 04/30/14 12:29:02PM
MAD
MAD
@madc
10 years ago
600 posts
Not sure if you want to be notified when you visit the site again but if not
wouldn't you be able to wrap it in an if statement on the page saying if this field is checked then send mail?
Otherwise you could make the check box a submit button maybe that would run a form php file easy enough to send all the fields in your module via a sendmail script.
Or it could trigger an admin alert that either sends the mail or alerts you next time you login....or both
Long way round...Just thinking out loud :)


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
If the module has a form save function, check the box field in that, and send notification if the field value is "on"


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
MAD
MAD
@madc
10 years ago
600 posts
does that exist? didn't know that . Could use this in multiple areas...going to look


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
Example:

This makes the form:
function view_jrBlog_update($_post, $_user, $_conf)

This does the save:
function view_jrBlog_update_save($_post, &$_user, &$_conf)

You'd probably want to do the checks after validation:
$_sv = jrCore_form_get_save_data('jrBlog', 'update', $_post);

And send the notification at the same time as adding to actions:
// Add to Actions...
jrCore_run_module_function('jrAction_save', 'update', 'jrBlog', $_post['id']);



--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
blindmime
@blindmime
10 years ago
772 posts
Thanks, Steve.

I wouldn't call myself a programmer, but I think I get what this is doing. I guess the jrAction_save function is doing something based on $_post['id'] which is the checkbox? Is there documentation or a module I can look at to bring me more up to speed?
brian
@brian
10 years ago
10,148 posts
$_post['id'] is the Item ID - that is what is used in the jrAction_save functions.

When a form is displayed in Jamroom, every field has a unique "name" - so the name of each field (and it's value) will come in as part of the $_post array.

So in your "save" function (the function that is the target of a form), you would access the checkbox as whatever you named the field - so if you called the checkbox field "mymodule_form_done", you could check for it in the save function like:

if (isset($_post['mymodule_form_done']) && $_post['mymodule_form_done'] == 'on') {
    // The "form completed" checkbox is ON - do your work here....
    jrCore_run_module_function('jrAction_save', 'create', 'myModule', $_post['id']);  // assuming $_post['id'] is the Item ID of the item we are finishing.
}

A checkbox in Jamroom will always have a $_post value of either "off" or "on".

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 03/18/14 06:09:21AM

Tags