Bulking Editing Field Data in Drupal with Views Bulk Edit

Published Sep 27, 2022
Updated Sep 27, 2022
By Simon

Views Bulk Edit module has to be one of my favourite modules. There is something pleasing about being able to select a bunch of content you want to modify in the same way and do it in bulk. Before you can set up the module, however, you will need to install Views Bulk Operations or VBO module, as Views Bulk Edit hooks into the views bulk operations custom actions AP. If you haven't installed VBO, please check out the first part, which explains how to install VBO and how to set up a view to use it. Once that is done, please read on.

Views Bulk Edit

Now we have the new VBO field set up for our view let's look at the Views Bulk Edit module, as I say this is the main reason I have used VBO as having the ability to bulk edit entity fields if an amazing feature.

I have used the Views Bulk Edit module in various situations from bulk updating field data from Drupal upgrades or adding new fields and then needing to add a value to all the old content in bulk. I have also used it in a custom gallery and album management system where after bulk uploading media image entities to an album you could tag the media entities to make them more searchable.

Info

https://www.drupal.org/project/views_bulk_edit

Actively maintained Yes, 15,500 sites report using it at the time of writing.
Requires Views Bulk Operations (VBO) https://www.drupal.org/project/views_bulk_operations
Libraries No library.

Install either using the UI or composer.

Basics

Once installed you will now find the new action in the VBO settings. All you need to do is check it and it becomes available.

Image
configure views bulk operations to use views bulk edit

You may want to limit what fields you can edit when using the views bulk edit functionality. For example, it doesn't really make sense to allow the bulk update of the title & body fields in most cases1. To limit the fields in the form you can add a form display mode, so let's take a look at how we can do that.

Image
views bulk edit modify field values default form
Views bulk edit modify field values default form has all the field and setting field which in most cases aren't needed. Let's fix that.

Limit the fields in the bulk edit form

To limit the fields that can be bulk edited you can add a bulk_edit form mode and configure it for each content type.
/admin/structure/display-modes/form

Manage >  Structure > Display modes > Form modes
/admin/structure/display-modes/form

  1. Click on + Add form mode.
  2. Choose content.
  3. Add Bulk Edit and make sure the machine name is node.bulk_edit 

    Image
    adding bulk edit form mode
  4. Click Save
     

Now visit the Content Type you want to add the form mode to and click on the Manage from display tab

Manage >  Structure > Structure > Content types  > Article 
/admin/structure/types/manage/CONTENT_TYPE/form-display

At the bottom of the Manage from display tab, you will see Custom display settings,

  • Open the element
  • Check Bulk Edit.
  • Click Save
Image
modify field values with new bulk edit form mode 144

Now you should have a secondary Bulk edit tab, click on this and

  • drag any field you don't want to use the bulk edit functionality to be disabled.
  • Click Save
Image
manage form display showing the custom bulk_edit form mode
Manage form display showing the custom bulk_edit form mode tab with diabled title field ready to be saved.

Using Views Bulk Edit

Now when you select a bunch of content to be bulk updated in the view you are only present with the fields that are allowed to be bulk updated. This is a much better user experience and also prevents someone from mistakenly updating a field for multiple pieces of content that shouldn't be.

In my case on only want to bulk update and manage tags so that is what I have set for now.

Image
modify field values form with custom form mode applied

Bulk Update Tags

A nice feature that is included as part of bulk edit tags is the fact that you can override the current tags or you can add to the tags.

Image
bulk edit tags in drupal
Bulk editing tags in Drupal can replace or add to a multivlaue field.

To bulk update the field you fill in the form and click apply, it is that easy.

That's it for view bulk edits, can you think of other uses or have you used it for other situations? I'd love to hear your different use cases for this awesome module combo.

If front-end development and design are your things, be sure to sign up for the newsletter by using the sign-up form below. I cover modern front-end development and also how you can use Drupal as a complete CMS or use it as headless CMS with a decoupled front-end. Thanks for reading and all the best with your day

1 Bulk update title field or URL field if using a token.