Page 1 of 1
another stupid question (adding functionality to submit)
Posted: Fri Aug 11, 2006 12:43 pm
by jmilane
I am using an add-on Drupal module that invovles forms and php scripts.
As it stands, once a form is filled out, it updates the database. Of course.
I ALSO want it to send an email. That means I have to go in and tweak the code.
Where would I look to insert this email code? Can I do it right there in the form? Id like to (and leave the php written by people who actually know how to write it alone) but how would I trigger the send unless via the submit button?
If the form is submitted to formhandler.php (I actually think it is dynamically derived), can formhandler.php see every variable on the form? I could set a flag so it would know to send an email and just stick the email code in formhandler.php
Makes my head hurt.
Can I set a variable in the form that is not part of the form and pass it along in the submit?
Sorry.
Posted: Fri Aug 11, 2006 1:06 pm
by nincha
Can I set a variable in the form that is not part of the form and pass it along in the submit?
?!?!?!??
are u talking about hidden fields? ( dosnt apeear to the user, but is sent with the submit?)
Posted: Fri Aug 11, 2006 1:07 pm
by jmilane
nincha wrote:Can I set a variable in the form that is not part of the form and pass it along in the submit?
?!?!?!??
are u talking about hidden fields? ( dosnt apeear to the user, but is sent with the submit?)
There I am, yes.
Posted: Fri Aug 11, 2006 1:08 pm
by neophyte
I am using an add-on Drupal module that invovles forms and php scripts.
Which module are you talking about? Webform?
Where would I look to insert this email code?
In modules/modulename.module.
If the form is submitted to formhandler.php (I actually think it is dynamically derived), can formhandler.php see every variable on the form? I could set a flag so it would know to send an email and just stick the email code in formhandler.php
You'll want to look in the module for a function called modulename_save() --- I think.
Can I set a variable in the form that is not part of the form and pass it along in the submit?
Yes look in the module for a function called modulename_form()
But of course before you do any of that I highly reccomend that you do some reading at
api.drupal.org.
Posted: Fri Aug 11, 2006 1:21 pm
by nincha
Can I set a variable in the form that is not part of the form and pass it along in the submit?
create a html form, ie. <input type="hidden" name="myVariable" value"myValue">, the variable shound be sent
Posted: Fri Aug 11, 2006 2:01 pm
by neophyte
Not with out modifying the modules. As far as I know you'll have to modify the form array found in modulename_form(); in modules/modulename.module
Posted: Fri Aug 11, 2006 2:47 pm
by jmilane
Okay let me try again... I am kind of out of it today and have not been clear.
This is really more of a question about how Php works.
My form submits TO a php file, right? I dont SEE any php at all on the form as it is. It looks like a regular html form. I dont know though. Would I see php? Or is it all on the file that receives it? (I cant actually find the file. It might be stored in the database somewhere).
And that file handles processing, gets passed ALL the variables on the form?
So there is no reason I couldnt modify the file to do extra processing, like sending emails before it is submitted to the database?
I can therefore pass variables (hidden fields) that the script is not now aware of... tack them on without doing any damage?
I am using an add-on module and I need to build more functionality into it. It does some seriously complicated database stuff, but I need it to do some other things (like send notification emails).
I appreciate your time.