Defaulting a value for a new boolean field added to an existing content type with content? We have a Drupal 8 site. For one of our features, I added a boolean field called 'Pinned' to a our Blog Post content type. 

As I added the filed as a filter criteria to views, I noticed that, no matter what configuration I selected, Is equal to + True, Is equal to + False, Is not equal to + True, Is not equal to + False, my view preview, which had had results, suddenly gave no results. I thought surely one of these combinations must apply to at least one node. 

I added the 'Pinned' field to the fields of the view to examine the values, and removed it from the filter criteria. It turns out that the field was technically NULL, from the join-- there was no record in node__field_pinned.field_pinned_value.

To further test, I edited one of our blog posts nodes. When I checked the 'Pinned' checkbox, the value in the view became 1. When I then unchecked the checkbox and saved the node, then value became 0. 

Trying to think of ways to auto-populate the field, I made the 'Pinned' field required.



But, all that did was make it necessary to check the checkbox when editing or adding a Blog Post.



This didn't solve my problem, and seemed to make the field redundant anyway. You can't save the node without checking the checkbox; you have to check it. 

Edit going off Grapple's answer, I found that if I changed the widget to "Check boxes/radio buttons" on the "Manage form display" page of the content type. This does allow you to set a default value, but it does not auto-populate existing node field values, nor does it auto-populate the form widget for existing nodes. 



It only auto-populates the form for new nodes.



It seems like a boolean field with a checkbox widget is meant for situations where the user cannot advance without checking the box, such as accepting terms of service, etc. 

As it is, it is difficult to use, because we have hundreds of Blog Posts, and it's pretty labor intensive to edit each one and check, then uncheck the box. We only want a few pinned posts, but we can't have views of unpinned posts being empty. 

Is there a way I can add a Boolean field to a content type with existing nodes and have it auto-populate with values?
If the field has a default value configured, you may be able to cause the "Pinned" field to be populated by bulk editing the nodes from the content overview page, and toggling a different value like 'Published', 'Sticky', or 'Promoted to front page'.



For a programmatic solution, implement hook_post_update_NAME to load the necessary entities and update the new field with the required default value.