i have some product types. Button "Save and add another" is doesn't work, it's only save the product.

Comments

rszrama’s picture

Status: Active » Postponed (maintainer needs more info)

Do you have any custom fields on the product types that don't work? We need to know how to reproduce the error to fix it. : )

zolee’s picture

Yes, I have custom fields: integer, list, image and long text.

rszrama’s picture

Hmm, ok. I have product types using similar field types and haven't had any "Save and add another" problems. Will look into those... only thing I can imagine interrupting the redirect process might be the image field, but I do my testing with an image field, too.

rszrama’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I just tested this using the exact same fields mentioned and "Save and add another" worked just fine. Closing this out as unreproducible.

jeffschuler’s picture

Version: 7.x-1.0-beta4 » 7.x-1.0
Status: Closed (cannot reproduce) » Active

I'm experiencing this too, in 7.x-1.0.

In debugging commerce_product_ui_product_form_submit() (when the Save and add another button is pressed,):

$form_state['triggering_element']['#parents'][0] is set to 'actions',
while $form_state['triggering_element']['#parents'][1] is set to 'save_continue'.

If I change that function to test index 1 instead of 0, the button works as I'd expect it to.

rszrama’s picture

Status: Active » Fixed

Alrighty, I just pushed a fix that changes the way I determine which button is pushed. In reality, it should be looking at the final element of the array_parents array on the triggering element. This way it isn't dependent on any particular order / tree. All I can figure is something is altering the forms of those it's failing for to make that submit element show up in a #tree parent container. Thanks for pointing out the problem with the array key - never would've found that on my own!

Commit: http://drupalcode.org/project/commerce.git/commitdiff/154a224

jeffschuler’s picture

Works for me. Thanks!

Might be because Commerce (Product Display Manager) is adding its display reference fieldset to the form...

rszrama’s picture

Yep, that could be the problem. Sounds like the module might not be using our form support properly, then... if the product form is being embedded anywhere, it should be instantiated as a form specific to that module. The reason the normal add another button isn't working is because it expects to be that one particular product entry form with that form structure.

It may be worth pointing this out to that module's maintainer and linking to http://www.drupalcommerce.org/specification/apis/instantiating-forms.

jeffschuler’s picture

#1289280: Breaks "Save and add another" product posted to Commerce (Product Display Manager) module

Status: Fixed » Closed (fixed)

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