1

I have a view of persons. I like to add the persons to an event. I also like to set the status of the resulting relation to one of the values "optional" or "required".

Therefore I use VBO on a list of persons. With the submitted NIDs I like to build a relation from the person to the event and fill the relation data field "status" with the selected value from the from.

To create only the relation it was easy to create a new action with custom php code, which builds my relations programmatically.

To add a parameter to the relation I have to edit the view's form programmatically. So I hook into the form alter of the views form and add a custom dropdown with the two values "optional" or "required".

The questions are:

  1. Is it possible to use the selected dropdown value in the vbo action with custom php code? I only know how to handle the selected nid's. This option would be easier for me to implement.
  2. If 1) is not possible: Should I use a custom submit function for the vbo form? And where to assign the function?

I tried the following code to assign a custom submit custom_webform_pre_build_list_vbo_submitfunction but it isn't called.

function custom_webform_pre_build_list_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == "views_form_person_list_panel_pane_9" 
    and $form['#id']=='views-form-person-list-panel-pane-9') {
        $form['#submit'] = array('custom_webform_pre_build_list_vbo_submit'); 
    }
}
1
  • VBO offers an API to create your own actions. You can find the documentation on drupal.org/node/2052067.
    – Raf
    Aug 24, 2016 at 13:56

1 Answer 1

-1

It is possible to use the $_POST array in the custom php code, which can be called in the action, which is assigned to the vbo action! The page to show the view with the vbo fields is: /node/%node/add_person_to_event, so arg(1) is the nid of the event.

So my custom action code is: $status = $_POST['status']; $event = arg(1); foreach ($_POST['views_bulk_operations'] as $key->$vbo_nid) { build_relation_person_event($event, $vbo_nid, $status); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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