Hi there,
I'm fairly news to Drupal and have followed the steps in the tutorial here: http://hokuten.net/2010/drupal-creating-an-e-mail-subscription-block/ in order to build a newsletter subscription block for my website consisting of two simple required fields: name and email. I want to be able to know for sure in my template that the user has successfully submitted a valid form and that their details have been saved to the database.
In the tutorial I've been following, the following code in the submit function sets a message which can be read by the template:
drupal_set_message('Thanks for subscribing!');
Ideally I need a boolean variable that I can check in the template that tells me that the form has been saved.
Any ideas?
Comments
Template can have preprocess
Template can have preprocess functions. These allow you to set up variables for use in your template. You will need to create a preprocess function, and in that function you will have to set up something to test to see if the form has been submitted. You then set the value inside the preprocess function, and it will be come available to your template.
Full-time freelancer, always looking for work.
jaypan.com (my portfolio)
Same problem in the
Same problem in the preprocess function as in the template. There isn't a variable that tells either if the form has just been saved.
Well no, there isn't. The
Well no, there isn't. The variables given to the preprocess function are the same ones that are given to the template. But you can do PHP inside your preprocess function and then use that data to create a variable for your template.
Without knowing how your module works, I can't help you as for what PHP to use. But there will be some way you can determine if the form has been submitted - a query to the database, or maybe you need to set a flag somewhere when the form is submitted so that you know it has been submitted. There are various ways it can be done, but it will all depend on how your module works.
Full-time freelancer, always looking for work.
jaypan.com (my portfolio)