When saving a new discount with one of the offer types this module adds I kept seeing

Notice: Undefined index: #language in inline_entity_form_cleanup_entity_form_state().

I tracked the problem to commerce_discount_extra_form_commerce_discount_form_alter() and commerce_discount_extra_fix_limit_data(). In both functions we're not digging deep enough in the form array to get the correct 'commerce_offer_limit' element.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

michfuer created an issue. See original summary.

michfuer’s picture

Status: Active » Needs review
FileSize
1.56 KB

This appears to resolve it.

rszrama’s picture

Status: Needs review » Fixed

Good catch, the result of some field reorganization on the form a while ago. Committed!

  • rszrama committed 9c10e76 on 7.x-1.x authored by michfuer
    Issue #2660016 by michfuer: Notice: Undefined index: #language in...
rszrama’s picture

Alright, this fix actually opened up a nasty fatal error bug when an empty string was submitted. The issue lies in the fact that you cannot write an empty string to the database, and before this patch, the code that caused the error was never being executed. So... this fix resulted in the exposure of another bug.

There were two issues with this code (not the patch, mind you):

  1. It wasn't using an element_validate handler, even though it should have to target validation of a specific element.
  2. It wasn't using form_set_value, just setting $form_state['values'] directly, which is insufficient.

I've rewritten the code accordingly.

Also, this is pretty crummy UX in general, because 0 will work the same as an empty value. Spawning a follow-up issue to update the help text in the suffix.

  • rszrama committed c0a17d0 on 7.x-1.x
    Issue #2660016 follow-up by rszrama: fix the code that attempted to...
rszrama’s picture

Relevant patch attached.

Status: Fixed » Closed (fixed)

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