0

So, I've been trying to implement a 'sample request' type webform using Flag, Webform, and Webform Views. The idea is to have a webform with a select list made from a view of Flags as implemented here through a custom moduleProgrammatic Sample Request, Drupal Steve.

The issue I'm having is that I can't seem to get a checkbox to show up in the view. I have followed the instructions at the webform views documentationWebform Views Docs by creating a boolean field with a checkbox widget. I'm Flagging Commerce products. I have even tried to add a boolean on Flags and add that into the view, but that didn't work either. Not sure is this is a Flags, Commerce, or Webform Views issue, but I wanted to report this here and see if anyone had any ideas.

2

Using drupal commerce (irrelevant), session_api, flags, views, webform4, custom content type (product display in my example), custom module.

Works even under anonymouse user

I think it's in select field settings.

Called "Multiple":

multiple

webform_flags.module:

    <?php 
 /**
 * Implements hook_webform_select_options_info().
 */
 function webform_flags_webform_select_options_info() {
    $items = array();
     if (function_exists('webform_flags_user_flag_sample_requests')) {
         $items['webform_flags_user_flag_sample_requests'] = array(
         'title' => t("User's flagged products"),
         'options callback' => 'webform_flags_user_flag_sample_requests',
         );
     }

    return $items;
 }

 function webform_flags_user_flag_sample_requests() {
     $view = views_get_view('user_flagged_products', TRUE);
     $options = array();
     if(isset($view)){
         $view->set_display('webform_options');
         $view->execute();

         if ($view->result) {
             //$row_class = $view->style_options['row_class'];
             //$attributes = $row_class ? " class='$row_class'" : '';
             foreach($view->result as $item) {
                //dpm($item->field_field_image);
                $options[$item->nid] = '<a>' . render($item->field_field_image[0]['rendered']) . $item->node_title .  '</a>';
         }
         }
         else {
            $options[0] = t("Nothing");
         }  
     }


    return $options;
 }

View's settings: view's settings

| improve this answer | |
  • See result. Can't post more than 2 links in post. =) – ar7max Aug 9 '15 at 15:07
  • This is a well-documents and thorough, answer! – nizz0k Aug 9 '15 at 20:19

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.