Topic: Modify eForm params after page load  (Read 419 times)

Pages: [1]   Go Down

#1: 5-Jun-2009, 12:13 PM


markhurd
Posts: 69

WWW
I have a form which needs to change based on user input of the form itself.  With my current project, the &to parameter of eForm should change depending on which option a user chooses from a <select> in the form. 

After reading through the documentation, it looks like one of the callback functions (specifically &eFormOnValidate) would help with this but I'm unclear how to use it to modify the eForm parameters itself, rather than the user-entered data.

Thanks!

#2: 9-Jun-2009, 11:52 AM


markhurd
Posts: 69

WWW
Any suggestions?  I've been trying eFormOnValidate and eFormOnBeforeMailSent but neither function will access the &to parameter.  I'd like to avoid cluttering up eform.inc.php if I can help it, since this functionality will need to be duplicated (with different email addresses) for a number of forms on the website.

#3: 9-Jun-2009, 12:18 PM

Moderator

TobyL
Posts: 1,023

If you read the documentation in snippets/eform/docs/eform.htm you'll see there's already a parameter for doing just that...

Quote
&mailselector (Optional)
Sets the name of the form field to use as a selector to select a single email from the comma (,) delimited emails assigned the &toparameter. This selector field will act like a numeric index to select an email. It will start at 1 for the first email and ends at N for the last email in the list.

For example: &to =`sales@me.com,support@me.com,billing@me.com` &mailselector=`topic`

On the web form the topic field is actually a dropdown menu. when the user selects a topic from the list the value 1,2 or 3 will be sent to eForm which will then be used to select one of the three emails assigned to the &toparameter. This email address will be the address used to send the email to.

#4: 9-Jun-2009, 01:22 PM


markhurd
Posts: 69

WWW
I saw the &mailselect option but it only seems to work if there's a 1:1 mapping between select options and email addresses.  Is there a way to assign multiple email addresses to a single option?

Thanks!

#5: 9-Jun-2009, 10:12 PM

Moderator

TobyL
Posts: 1,023

I saw the &mailselect option but it only seems to work if there's a 1:1 mapping between select options and email addresses.  Is there a way to assign multiple email addresses to a single option?
Thanks!
That's correct. Sadly the parameters are not available (to write to that is,.. you can however read them using $modx->event->params) in the event functions. Your only option to send emails to multiple addresses that depend on form input is to write your own mailing code inside the event function.  You could duplicate some of the code in eform.inc.php.
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.