Restrict editing of content based on form value in content type I'm not sure of the exact way to word this. I'm "just the designer". Where I'm working we've traditionally made a role per content type to limit access to editing/creating certain kinds of content. On a new (D8) site we're working on, we'd like to have a single content type ("Room") and have different people be maintainers of those rooms depending on what's set in the "Building" field. 

The idea is to avoid having a ton of mostly-similar Room content types (that would all require updating when we want a change). And also of course to avoid people from other buildings editing rooms that don't belong to them.

(I think it'd be fine to have either 1) the rooms originally created by an admin and just have the building field hidden/disabled/limited when non-admins edit, or 2) even let them create new rooms with the building field limited based on their role/permissions.)

I don't know if there's a built-in way to do this, or perhaps modules you could recommend. 

The developer I'm working with seems convinced that the only way to accomplish this is to build a custom form in PHP that essentially duplicates Drupal's built-in form for the Rooms content type we've made (I'd really like to avoid this route, since it'd be a lot of hard-coded stuff that needs dev time, testing, maintenance, etc.). Thanks!
(I think it'd be fine to have either 1) the rooms originally created
  by an admin and just have the building field hidden/disabled/limited
  when non-admins edit, or 2) even let them create new rooms with the
  building field limited based on their role/permissions.)


You could do this via a custom module or in your theme's mytheme.theme

function mytheme_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  // check form id for edit
  if($form_id == 'node_room_edit_form') {
    // Load the current loggedin user.
    $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()-&gt;id());
    // Check if user does not have administrator role
    if(!$user-&gt;hasRole('administrator')) {
      // get current node id
      $nid = \Drupal::routeMatch()-&gt;getParameter('node');
      // load the node
      \Drupal\node\Entity\Node::load($nid);
      // check if building field is not set to something
      if($node-&gt;field_building-&gt;value != 'something') {
        // remove access to field, make field not required so when 
        // they save they don't get an error.
        $form['field_name']['widget']['#access'] = FALSE;
        $form['field_name']['widget']['#required'] = FALSE;
      }
    }
  }
  // check id for create
  if($form_id == 'node_room_form') {
    // logic goes here.
  }
}