Closed (fixed)
Project:
Inline Entity Form
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Jan 2013 at 20:49 UTC
Updated:
7 Jan 2014 at 19:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bojanz commentedEDIT: Confirmed.
Comment #2
nigelw commentedYep. Can confirm this too.
Steps to reproduce.
Node is saved and you were't forced to either select an existing product entity or to create a new one.
Comment #3
timwoodI can confirm this as well, not using Commerce.
Comment #4
cellar door commentedAlright I've put together a patch that hopefully will work. I put it in the inline_entity_form_save_row_weights since that seems to be the #element_validate for the multiple add widget. Works on my setup but I'm using it with Nodes so it'll need some testing.
If there's a better way to do it let me know and I can re-roll
Comment #5
vasikei also confirm the issue.
the patch from #4 seems to provide the solution.
there's a little "trailing whitespace" in the patch.
here is a new patch whithouth the "trailing whitespace".
Comment #6
cellar door commentedActually I just found a bug in my code - It trips an error when the IEF is filled out but not "saved". I'll re-write the patch with this in mind and push up later today/tomorrow.
Thanks for catching the trailing whitespace vasike!
Comment #7
bojanz commentedWaiting for a new patch then :)
Comment #8
cellar door commentedBojanz -
I've looked into it more and it seems that this issue may be 2 part. The patch I submitted up above looks for a saved IEF form on required fields. This works as designed but the following situation needs further exploring:
Usually when an IEF is filled out but not "submitted" the main submit for the node form submits all the IEF forms and processes as normal. However when this happens, the form_error does not stop this process. What happens is the error is triggered but the entire form is submitted in the background and then the error showed.
So there are 2 options here:
1. If multiple IEF not saved the form does not save
2. Iterate through form for required fields and set error if values not given.
What do you think?
Comment #9
dwwSounds a bit like this might be related to the bugs with nested IEF. In my case, I'm seeing duplicate entities getting created on a grandparent form when the parent form uses IEF to try to create a child. ;) Perhaps it's related to this background form submit magic. I still haven't had a chance to dig into the code, but just wanted to raise it as another possible data point...
Thanks,
-Derek
Comment #10
vasikehere is a new patch that should solve the issue mention at #6 - filled IEF.
built on separate validation function.
also add the the required marker to IEF label.
Comment #11
dave reidUpdating to major based on https://drupal.org/node/45111
Comment #12
tannerjfco commentedPatch applied against 7.x-1.3 & tested. Works if widget is configured as single value, but does not work if widget is configured as multiple values and no action is chosen on the multiple value widget - that is, if the form is submitted without either selecting "add new" or "add existing", the form will still submit without a reference being made. If "add new" or "add existing" are selected, and the required values aren't filled, the form will fail validation as expected.
Comment #13
vasike@Tannerjf : indeed. Thank you Sir.
here is patch that corrects that and also removes some trailing whitespaces from previous one.
Comment #14
tannerjfco commentedSorry for the delay, but I finally got this tested again, and the issues I noted in #12 look to be fully resolved. I think we're ready to roll here :)
Comment #15
pixelsweatshop commentedCan confirm patch works as well. Thanks @vasike.
@bojanz, do you have some time for a small commit/release, seeing as how this is pretty major?
Comment #16
JulienD commentedThe patch is solving the issue, multiples inline entity form are now marked as required.
Comment #17
bendiy commented#13 works fine from a main form, but stops working if the form is embedded in another form.
For example, add an IEF multiple field to Commerce's Customer Billing profile and make it required. If you're editing an order directly, the required IEF is enforced:
example.com/admin/commerce/orders/x/edit
However, if you go through the checkout process that uses panes to embed the profile and handle the submit, the required IEF is not enforced:
example.com/checkout/x
It appears to be caused by using the 'triggering_element' to enforce the requirement:
Comment #18
bendiy commentedThe attached patch checks for:
I'm not sure if this is the best way to find the parent submit button, but I'm assuming if there is more than 1 parent, this is a child submit and not the final parent submit button. This fixes this issue I raised in #17.
Is there a better way to tell when the parent submit button on a form is being clicked?
Comment #19
bojanz commentedReworked the patch and committed it:
http://drupalcode.org/project/inline_entity_form.git/commitdiff/2e16596?...
The validation runs only if the add new / add existing form is closed, since the submission of that form does the job for us (either by preventing submission of the parent form, or by adding a new referenced entity).
Added a code comment to explain this.
Also made the required message match other drupal required messages.
I've reverted bendiy's fix for nested forms because it's not the job of this issue to fix nested IEF's.
Let me know if you encounter any issues.