0

I have some nodes like this http://sprachzentrum.com.ar/cursos/curso-intensivo-de-alem%C3%A1n-nivel-a21-agosto-2011 and webforms and want to insert titel and day field as an option in the webform.

So that the user can choose from different levels


thanks of course! My question was: I have a node with an titel and some customer fields like level an time an I ask myself if its possible tu render the listbox automaticaly so that i will a options like:

1| [custom-field-level-1] [node-title-1] [custom-field-time-1]
2| [custom-field-level-2] [node-title-2] [custom-field-time-2]
3| [custom-field-level-3] [node-title-3] [custom-field-time-3]

So for each node from a certain type I will get an option on my webform

  • Which drupal version are you using ? – tostinni Jun 19 '11 at 17:30
2

For both level and date (I understand these are session, so a range of date), you can add some "select list" in order to let the user select between the available options. Do you have troubles adding this ? Can you make your question a little clearer regarding what you want and what causes you difficulties ? enter image description here

Select the "listbox" option and it will produce:

enter image description here

Edit June, 23:

  • so you have a Content Type named "webform_info" with some fields "field_level" and "field_time".
  • the idea is to implement a hook_form_alter (in a custom module) to retrieve these fields and put them in the webform
    <?php
    function custom_form_alter(&$form, &$form_state, $form_id) {
      //you need to set up a custom module to store this.
      //use devel with dsm($form); to figure the name of each field
      if ($form['#id'] == 'webform-client-form-123') {
        //delete the array of options from the webform field, they start by "con_"
        $form['submitted']['con_level']['#options'] = Array();
        $form['submitted']['con_level']['#options'][''] = '- Select one level/time -';
        $i = 1;

        //retrieve the nodes of the type webform_info
        $result = db_query("SELECT nid FROM {node} n WHERE type = 'webform_info' AND status = 1");
        while ($row = db_fetch_array($result)) {
          $node_level = node_load($row['nid']);
          $form['submitted']['con_level']['#options'][$i] = $node_level->field_level[0]['value'] . $node->title . $node_level->field_time[0]['value'];
          $i++;
        }
      }
    }
    ?>

Doing node_load can be pretty heavy if you have a great number of nodes, so you might want to use the CCK table structure, have a look at another answer to adapt the code.
Code is for D6 but should give you some insights to apply this to D7 if needed.

  • 1
    @Daniel, was what ? :) – tostinni Jun 19 '11 at 16:06
  • My question was: I have a node with an titel and some customer fields like level an time an I ask myself if its possible tu render the listbox automaticaly so that i will a options like: 1| [custom-field-level-1] [node-title-1] [custom-field-time-1] 2| [custom-field-level-2] [node-title-2] [custom-field-time-2] 3| [custom-field-level-3] [node-title-3] [custom-field-time-3] So for each node from a certain type I will get an option on my webform – Daniel Jun 19 '11 at 16:33
  • @Daniel I edited my answer to give you some code. – tostinni Jun 23 '11 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.