Book Image

Drupal 7 Webform Cookbook

By : Vernon Denny
Book Image

Drupal 7 Webform Cookbook

By: Vernon Denny

Overview of this book

<p>The Drupal Content Management System puts everyone in charge of their own internet destiny. Webform takes this power a step further by ensuring that you are never more than just a few mouse-clicks away from fully functional information-gathering forms. From simple contact forms to advanced web applications, Webform provides a solid tool set for both the novice and the expert.<br /><br /><em>Drupal 7 Webform Cookbook</em> gives you everything you need to achieve in minutes what previously cost hours in development and testing. Practical demonstrations of every facet give both the technical and the not-so-technical users an in-depth understanding of how things work.<br /><br />Install. Use. Customize. Extend. A mammoth learning curve devoured in small bytes: all digestible, with no choking.<br /><br />From designing coherent forms, to sending pretty HTML emails and managing data, explore the rich scope of possibilities that Webform enables. Also, easily extend and tune Webform with custom components and functionality.<br /><br />With <em>Drupal 7 Webform Cookbook</em> you are placed firmly in the driving seat.</p>
Table of Contents (18 chapters)
Drupal 7 Webform Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Creating a conditional action


As explained in the requirements specification at the start of the chapter, we only need our action to show up on the submission View and Edit pages if the current submission has a status of Accepted. We will utilize the hook_webform_submission_actions() hook exposed by Webform to add this programming logic.

How to do it...

Let us add the programming hook to our webform_custom_action.module file.

/**
* Implements hook_webform_submission_actions().
*/
function webform_custom_action_webform_submission_actions($node, $submission) {
$actions = array();
// Does this submission already have Declined status?
$declined = FALSE;
if (isset($submission->data[19]['value'][0])) {
if ($submission->data[19]['value'][0] == 'Declined') {
$declined = TRUE;
}
}
// Show action if user has results access and submission not already declined.
if (webform_results_access($node) && !$declined) {
$actions['declined'] = array(
'title' => t('Decline speaker'),
'href' =...