Widgets

Webform options for the event -d7

Actions

A lot of other actions are allready defined. For our actions we ‘ll allready have the mail and message action available to us. We configure the “send a mail to a user” and to do this we’ll need some tokens.

HOOK

To get custom tokens in drupal we’ll use the token api functions hook_token_values () and hook_token_list() (you ll put this piece of code in your_module.module)

The scenario

Why would you want to do this? Let’s suppose you are using Webform to allow your site users to register for upcoming events. In the old days it worked like this: you added a select component to your Webform, and then hand-entered the upcoming events. When the date of an event passed, you would have to go back to your component and update the list. It was either that, or you had to implement hook_form_alter, which is no fun.

 

/**
   * Provide a select options component to Webform. The values are 
   * populated via a call to _demo_get_options, which returns 
   * an array of nodes.
   *
   * @return void
   * @author Kosta Harlan
   */
  function demo_webform_select_options_info() {
        $items = array();

        if (function_exists('_demo_get_story_nodes')) {
                $items['story-nodes'] = array(
            'title' => t('Story nodes'),
            'options callback' => '_demo_get_story_nodes',
          );
        }

        if (module_exists('views')) {
                $items['views'] = array(
                        'title' => t('A view'),
                        'options callback' => '_demo_get_view_options',
                );
        }

    return $items;
  }

 

VIDEO:

SOURCES

sources:https://designhammer.com/blog/providing-dynamic-select-options-webform-module-drupal

http://drupal.stackexchange.com/questions/78877/how-to-write-webform-settings-and-conditions-programmatically

https://designhammer.com/blog/providing-dynamic-select-options-webform-module-drupal

Add your comments

Loading Facebook Comments ...
Loading Disqus Comments ...