2

I have a content type with title and image field in it. Now, I want to show a form to the user which will show the image thumbnail, title and a checkbox below each image with the value of respective nid. So that user can select the image they like and submit it. Which will eventually take the nid and do some actions depending on the selected nid.

My question is how I will create such form from that content.

1 Answer 1

0

Like most things in Drupal there are a couple of different ways you could do this. A quick look into the challenge, reveals the Webform View module. Basically, it allows you to pull in a viw (list of your nodes) as selectable items, for a webform. Webforms are good if all you want to do is store (and email of course) the submitted values of a form for manually processing later. Webforms are typically used for feedback, survey, contact forms.

If you need to do something a little more flexible with the submitted values, alternatively you could use the Views Bulk Operations (VBO) module (add-on for Views) which provides this kind of functionality plus a lot more if you need it for other purposes too.

Basically, you would create a view listing your content items with the fields you want to display, and then add a "Bulk operations: Content" field, and select the "Pass ids as arguments to a page", and then specify the path you want the arguments sent to. The path could then be defined in your custom drupal module, and you could use the $arguments = func_get_args(); to get all the arguments sent through. e.g. in a sandbox_test.module

function sandbox_test_menu() {
  $items = array();

  $items['test-submit'] = array(
    'title' => 'VBO Test Submission handler',
    'page callback' => 'sandbox_test_vbo_test',
    'access callback' => TRUE,
  );

  return $items;
}

function sandbox_test_vbo_test() {
  $output = '';

  $args = func_get_args();
  if (is_string($args[0])) {
    $items = explode(",", $args[0]);
    $output .= '<pre>' . print_r($items, true) . '</pre>';
  }
  else {
    $output .= 'None found';
  }

  return $output;
}
1
  • Ah! one reply at last :) I was looking to this page every minutes to see if any answer is posted. And now, even the first reply looks very promising. I will give it a try. If it work, I will make it as accepted answer. Thanks for your reply anyway.
    – moshfiqur
    Jun 18, 2013 at 13:04

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.