Example config:

Node types: Car, Part
Entity reference field parts on car.
Inline entity form (Multiple) "Parts" on "Car"
Flag "Working" on Car.

When adding a Part at the Car form, node type is required, otherwise the following error will appear:

Notice: Undefined index: type in flag_field_attach_form() (line 727 of flag.module).

Patch attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jgullstr’s picture

Forgot patch

jgullstr’s picture

Assigned: jgullstr » Unassigned
Issue summary: View changes
bojanz’s picture

Title: Compability with flag module » Inline Entity Form / Flag compatibility
Project: Inline Entity Form » Flag
Version: 7.x-1.3 » 7.x-3.x-dev
Component: Code » Flag core

I have no problem with committing that workaround to IEF, but I first want to ask the Flag team why they need to depend on a value from the node form in their field_attach_form implementation. Can't $entity->type be used instead?

joachim’s picture

You mean this bit:

      // Apply the per-bundle defaults for nodes.
      if ($entity_type == 'node') {
        $flag_status = variable_get('flag_' . $flag->name . '_default_' . $form['type']['#value'], 0);
      }

My only hunch is that it could be because on node creation forms there is no node object. I don't remember if that's the case or not.

I'll take a patch, but ideally with tests to show it still works!

bojanz’s picture

Well nobody can call field_attach_form() without an $entity, so I don't know how there can be no node object.
I won't be supplying patches, just reporting that I detect possible code smell :)

joachim’s picture

Ah, right you are.

Patch without tests should be fine then -- though I was fishing for one from the OP rather than bojanz ;)

joachim’s picture

joachim’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

scuba_fly’s picture

Issue summary: View changes

Fixed flag link