$Id$

The Dynamic Select module allows a user to add a dynamic component to the Webform 3.x module. You can populate a select list via PHP code. This is useful if you need to provide a select list of upcoming events, for example, and you don't want to update the list each time the date of an event passes.

Installation
============

Unpack the Dynamic Select module in your 'sites/all/modules' folder and enable it.

Permissions
===========

IMPORTANT: anyone who has permissions to create or edit a Webform has permissions to use this component, and consequently run arbitrary PHP code on your site.
Be very careful in specifying permissions for who can edit or create a Webform.

Requirements
============

This module will only work with Webform 3.x. It has been tested with Webform 3.0-beta2.

Usage
=====

Enable the Dynamic Select module. Create a Webform or edit the Webform to which you wish to add a dynamic select component. Under "Type" you should now see a component called "Dynamic Select". Enter a component name and click "Add". 

All fields are similar to what you are provided with in the other Webform component options. The exception is the "Options" field. You can enter PHP code in this field. Your code must return an associative array; the values in the array are what will be saved in the Webform results table. Keys can be whatever you prefer.

Again, please allow only the most trusted users on your site to create a Webform. Anyone who has permissions to create or edit a Webform will now have the ability to execute arbitrary PHP code, which means they can gain access to any area of your site along with the server it is hosted on.

How to populate a select list with node titles from a View
==========================================================

Create a View (http://drupal.org/project/views) that displays the items you wish to populate your select list with.
Create your Dynamic Select component. In options, enter the following code, leaving out the <?php ?> tags and replacing 'my_sample_view' with the View name:

<?php
$view = views_get_view('my_sample_view', true);
$view->execute();
$items = array();

foreach ($view->result as $item) {
  $full_node = node_load($item->nid);
  $items[$item->nid] = $full_node->title;
}
  
return $items;
?>

Save your component. Your list will now be populated with the items specified in your view.

Authors
=======

This module was authored by kostajh <kosta@designhammer.com>, gloryfish <jay@designhammer.com>, and Bartezz <bartezz@gmail.com>.

Sponsorship
===========

Development of the Dynamic Select module for Webform 3.x was sponsored by DesignHammer Media Group <http://www.designhammer.com>.