Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I installed both
version = "7.x-1.0-beta1+6-dev"
and
version = "7.x-1.0-beta1"
Drupal 7.14
this modules is great but I cant add more than one product reference to my display node.
The site is multilingual but thats hardly the reason - cause I tried the same thing with a commerce kickstarter vanilla instlall.
I tried both versions from above- no luck...
Our use case is a 1-1 product-display ratio and this is not a problem... but....
Here is a small screencast of the bug.
http://bit.ly/drupal-commerce-inline-entity-form-module-cant-add-more-th...
Comment | File | Size | Author |
---|---|---|---|
#12 | IEF_cardinality_check-1606076-10.patch | 2.14 KB | andyg5000 |
#8 | IEF_cardinality_check-1606076-7.patch | 2.12 KB | andyg5000 |
Comments
Comment #1
eme CreditAttribution: eme commentedIndeed, I can confirm the bug. Products are correctly added, but after saving, the product reference is not added it seems.
Comment #2
eme CreditAttribution: eme commentedOk. I'm just silly : I've put 1 product only in the widget, and not illimited.
So it's no critical bug : just edit the widget type and put 'illimited'.
Still a bug, as it is not possible to configure the widget as not being unlimited : if so, the button is still there even if the specified number is reached.
Comment #3
rsvelko CreditAttribution: rsvelko commentedaha! wow / omg / etc! Thanks dude .
I tested it after changing the reference field on the prod-display manage fields page - now all works...
So the module's fix would be:
- add a short text with a hint above of / on the same line to the "Add variation" button - a text saying: "currently this widget is set up to allow X products. To change that number go here ( link-url is admin/structure/types/manage/content-type-example/fields/field_example_reference"
What is left to be coded is to:
- find the place in the module where the form is generated
- add a "#after" / "#before" fomr API element with the hint
- to generate the hint - get the current node type and hyphenate its name if not done
- get all its entity fields and filter for a product reference
- build the settings page url and build the link with l() and t()
tadaaaa
anybody willing to crowdfund/sponsor this with 20 eur so that I will do it? Or maybe I will find some whole in my time and do it as usual 4 free...
Cheers..
Comment #4
rsvelko CreditAttribution: rsvelko commentedthis issue is a docs defficiency but we need the docs where appropriate in teh form itself... not hidden in the readme...
context based help is the next big drupal thing - imagine a tiny hover icon with a youtube vid related to each tiny button/setting in drupal ? This is context help. And I once saw a module for drupal is already here... forgot the name...
Comment #5
bojanz CreditAttribution: bojanz commentedYeah, IEF needs to handle this better. It is currently only optimized for unlimited values.
I was thinking of not showing the add button anymore when cardinality is reached, and always showing a message notifying the user about the maximum allowed number of entities.
See also this issue: #1598296: Add a simplified widget for fields that accept only one entity of a specific type where I'm attempting to optimize for cardinality 1 (showing the inline form in a fieldset, no table, no buttons).
Comment #6
rsvelko CreditAttribution: rsvelko commentedso this issue is redundant - lets make it a task then - a task to document
And with the pointed above tasks done a hint may become not necessary.
Comment #7
bojanz CreditAttribution: bojanz commentedOkay, so #1598296: Add a simplified widget for fields that accept only one entity of a specific type was committed, which means we now handle optimally both cardinality: 1 and cardinality: unlimited.
We now need to handle the other cases, by showing the maximum number of values in the widget #description, and hiding the "add" button once that number is reached.
Comment #8
andyg5000Here's a patch that compares cardinality to number of entities referenced. It updates the $element description and prevents adding more entities if cardinality has been reached.
Comment #9
andyg5000Setting as needs review
Comment #10
joachim CreditAttribution: joachim commentedQuick eyeball review. All nitpicky fiddly stuff :)
sizeof is an alias of count according to PHP docs -- it's probably better code style to stick to one.
FieldAPI has a special constant for the unlimited cardinality; don't use -1.
Also, shouldn't 'Unlimited' be translated?
Needs a space after the if
Indentation is wrong.
Also, comments need a full stop.
Comment #11
joachim CreditAttribution: joachim commentedThis also about how IEF lets me attempt to add further items, but then loses them if I've gone over the cardinality -- hence that's data loss and hence a bug :)
I've applied the patch and I can confirm it's no longer letting me go past the cardinality in the UI.
Comment #12
andyg5000Thanks for the review @joachim. Here's and updated patch.
Comment #13
marcin.wosinek CreditAttribution: marcin.wosinek commented#12 patch works really nice. I've tested in commerce environment, and outside (reference from node to node).
@andyg5000 thanks for the patch!
Comment #14
bojanz CreditAttribution: bojanz commentedTweaked the wording, made the message not show up if the field is unlimited, fixed a bug, committed. Huge thanks, Andy!
http://drupalcode.org/project/inline_entity_form.git/commitdiff/9483464?...
Comment #15.0
(not verified) CreditAttribution: commentedchanged link