Have a child node inherit taxonomy from a parent during /node/add? In Drupal 7, I have two content types:

Parent Events with tags (like &quot;outdoors&quot; or &quot;popular&quot; or &quot;suitable for kids&quot;). &quot;Tags&quot; are taxonomy terms in a vocabulary, connected via an Entity Reference field field_parent_tags (using the Checkboxes widget).

Child Events with the same tags &amp; reference in field_child_tags. Each Child also has a mandatory Entity Reference to a Parent Event, field_parent_event (using the Autocomplete widget).


I'm trying to have new Child Events automatically inherit their parent's tags when they're first created. For example:

There is a Parent Event called &quot;Weddings&quot;, which has the tags &quot;suitable for kids&quot; and &quot;popular&quot;.
When I make a new Child Event called &quot;Joe &amp; Sarah's Beach Wedding&quot;, I'd like it to automatically inherit the tags &quot;suitable for kids&quot; and &quot;popular&quot;. Then I'd add the &quot;outdoors&quot; tag to this specific child event, which would apply only to this child and not the parent.
(Another child event might be someone else's wedding, and not suitable for kids, so I'd uncheck that in the child event).

How would I go about doing that? So far, I think I need to implement some variation of hook_form_alter(), possibly overriding its #ajax call so that as soon as the child event's form_parent_event is filled out, its field_child_tags will copy the values from field_parent_tags.
Am I going down the right path? I can't figure out where to put that code, if so. I tried overriding /node/add/childevent using a page--node--add-child-event.tpl.php file, but it seems to have no effect. A little lost :(
Any help would be very much appreciated. Thank you!
I ended up using the Rules module for this. It couldn't do it in AJAX when the parent field was specified, but it could make this happen as soon as the child was first saved, and only if its taxonomies were left blank.

The main rule fires a Ruleset component when a child event is saved, and if the parent event is specified. This Ruleset has two parameters: 1) the parent node and 2) the child node.

Next, the Ruleset component just fires two child rules one after another, one for each set of taxonomy terms:

Finally, each individual child rule checks to see if the child event left its taxonomy blank, and if so, sets it to the parent's. I needed one child rule per taxonomy, so that the empty conditions could be checked individually.

That's it! New child events, upon saving, would get the parent tags if it had none of its own.
The code for the rule:
{ &quot;rules_inherit_parent_event_taxonomies&quot; : {
    &quot;LABEL&quot; : &quot;Inherit Parent Event Taxonomies&quot;,
    &quot;PLUGIN&quot; : &quot;reaction rule&quot;,
    &quot;OWNER&quot; : &quot;rules&quot;,
    &quot;REQUIRES&quot; : [ &quot;rules&quot; ],
    &quot;ON&quot; : { &quot;node_insert--event&quot; : { &quot;bundle&quot; : &quot;event&quot; } },
    &quot;IF&quot; : [
      { &quot;node_is_of_type&quot; : { &quot;node&quot; : [ &quot;node&quot; ], &quot;type&quot; : { &quot;value&quot; : { &quot;event&quot; : &quot;event&quot; } } } },
      { &quot;NOT data_is_empty&quot; : { &quot;data&quot; : [ &quot;node:field-program&quot; ] } }
    ],
    &quot;DO&quot; : [
      { &quot;component_rules_set_child_taxonomies&quot; : { &quot;parent_node&quot; : [ &quot;node:field-program&quot; ], &quot;child_node&quot; : [ &quot;node&quot; ] } }
    ]
  }
}

And the ruleset component:
{ &quot;rules_set_child_taxonomies&quot; : {
    &quot;LABEL&quot; : &quot;Set Child Taxonomies&quot;,
    &quot;PLUGIN&quot; : &quot;rule set&quot;,
    &quot;OWNER&quot; : &quot;rules&quot;,
    &quot;REQUIRES&quot; : [ &quot;rules&quot; ],
    &quot;USES VARIABLES&quot; : {
      &quot;parent_node&quot; : { &quot;label&quot; : &quot;Parent Node&quot;, &quot;type&quot; : &quot;node&quot; },
      &quot;child_node&quot; : { &quot;label&quot; : &quot;Child Node&quot;, &quot;type&quot; : &quot;node&quot; }
    },
    &quot;RULES&quot; : [
      { &quot;RULE&quot; : {
          &quot;IF&quot; : [
            { &quot;node_is_of_type&quot; : {
                &quot;node&quot; : [ &quot;parent-node&quot; ],
                &quot;type&quot; : { &quot;value&quot; : { &quot;program&quot; : &quot;program&quot; } }
              }
            },
            { &quot;node_is_of_type&quot; : {
                &quot;node&quot; : [ &quot;child-node&quot; ],
                &quot;type&quot; : { &quot;value&quot; : { &quot;event&quot; : &quot;event&quot; } }
              }
            },
            { &quot;data_is_empty&quot; : { &quot;data&quot; : [ &quot;child-node:field-topic&quot; ] } }
          ],
          &quot;DO&quot; : [
            { &quot;data_set&quot; : {
                &quot;data&quot; : [ &quot;child-node:field-topic&quot; ],
                &quot;value&quot; : [ &quot;parent-node:field-topic&quot; ]
              }
            }
          ],
          &quot;LABEL&quot; : &quot;Inherit parent\u0027s topics if child has none&quot;
        }
      },
      { &quot;RULE&quot; : {
          &quot;IF&quot; : [
            { &quot;node_is_of_type&quot; : {
                &quot;node&quot; : [ &quot;parent-node&quot; ],
                &quot;type&quot; : { &quot;value&quot; : { &quot;program&quot; : &quot;program&quot; } }
              }
            },
            { &quot;node_is_of_type&quot; : {
                &quot;node&quot; : [ &quot;child-node&quot; ],
                &quot;type&quot; : { &quot;value&quot; : { &quot;event&quot; : &quot;event&quot; } }
              }
            },
            { &quot;data_is_empty&quot; : { &quot;data&quot; : [ &quot;child-node:field-audience&quot; ] } }
          ],
          &quot;DO&quot; : [
            { &quot;data_set&quot; : {
                &quot;data&quot; : [ &quot;child-node:field-audience&quot; ],
                &quot;value&quot; : [ &quot;parent-node:field-audience&quot; ]
              }
            }
          ],
          &quot;LABEL&quot; : &quot;Inherit parent\u0027s audiences if child has none&quot;
        }
      }
    ]
  }
}