Closed (fixed)
Project:
Inline Entity Form
Version:
7.x-1.0-beta4
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Apr 2012 at 18:26 UTC
Updated:
10 Nov 2015 at 18:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bojanz commentedIt's on my todo list, though probably not soon.
I need to add an "actions api" first, so that people can provide actions other than the "add" one, such as "reference existing' and "bulk add".
Comment #2
joachim commentedThis is something I'm going to need on a project.
bojanz, could you perhaps sketch out a bit more of how you envisage this should be built, as I may start looking at it before you get to it :)
Comment #3
larowlanguys, I may also have some time to contribute on this.
My 2c - the inline entity form should let you choose an alternate widget (from the list of enabled widgets) for selecting an existing one
Comment #4
Anonymous (not verified) commentedYes this is exactly what I need too.
@joachim I don't suppose you've made any progress with this?
Could we start by copying the functionality of the default "Autocomplete text field" widget, and attach that onto the bottom of the "Inline entity form" widget? Any pointers as to where this code might be found would be appreciated.
Comment #5
jddeli commentedIs there any progress?
Comment #6
bojanz commented@jddeli
There is no such thing as a critical feature request. You're free to code it yourself and submit a patch if it's urgent.
@others
Being able to choose another widget to be used for selecting sounds good. Make it work, and I can make the code pretty afterwards.
Comment #7
jddeli commentedIs there any progress?
Comment #8
bojanz commentedNo progress. And no silly issue status change will make that happen faster.
Comment #9
jddeli commentedI have to put over 1.000 or more product entities that i have already added.
I need this to work. So it is critical bojanz.
If there is an ather solution please tell me.
Comment #10
bojanz commentedI told you to learn how to behave on drupal.org (on the unrelated issue you spammed).
I told you to stop changing and abusing the issue statuses.
You chose to ignore all that, instead of opening a support request and waiting for me to help you.
Because of that, you will not be getting any help from me, or any further responses. Have a nice day.
Comment #11
jddeli commentedThis does not help anyone who has a problem bojanz.
The Domination of a man to others for a directive on the need for a problem he wants to show that no solution you want to help anyone.
I will insist to ask because I have a problem.
Is there any progress?
Comment #12
timmillwood"A do-ocracy (also sometimes do-opoly, which is a more obvious pun on 'duopoly') is an organizational structure in which individuals choose roles and tasks for themselves and execute them. Responsibilities attach to people who do the work, rather than elected or selected officials."
Comment #13
jddeli commentedThis means that not to give attention to what was said and wait for someone to help me concerned.
Comment #14
Anonymous (not verified) commented@jddeli
This is not true. I would really like this feature as well, but that does not mean it is critical to the IEF module. I'm sure it will get implemented eventually (perhaps even by me), but unless you do it yourself, you cannot demand it get done immediately.
If you change the widget back to "Autocomplete text field", you can add existing Products by their SKU, or you can use the Commerce PDM module to manage the relationships between Products and Product Displays using a drag-and-drop interface. Either way, arranging 1000 Products is going to take a while...
Comment #15
jddeli commentedThanks for the reply and suggestion jackocnr .
I will try and we'll comment later.
Comment #16
jddeli commentedPerhaps the best way is to use are:
1. Put two variations.
a). A Final Product reference with Check boxes/radio buttons to select existing products.
b). A variations with Inline entity form to create new products.
2. After a pick in the products we create from the b.
3. In the manage display show only a).
Comment #17
joachim commented> @others
> Being able to choose another widget to be used for selecting sounds good. Make it work, and I can make the code pretty afterwards.
You said something about an actions API further up. Could you roughly sketch out how you envisage that being put together?
Comment #18
jddeli commentedPerhaps the best way is to use are:
1. Put two variations.
a). A Final Product reference with Check boxes/radio buttons to select existing products.
b). A variations with Inline entity form to create new products.
2. After we create new products with b.
3. And we choose the product with a)
4. In the manage display we show only the a) approach
Comment #19
andyg5000Has anyone other than @bojanz (I think translates to busy man) started to work on this? If so, message me and I'd like to see where we're at with it and how we get the ball rolling. I talked to @rszrama about adding a new button for "Add existing variation" that brings in a product autocomplete like the on on an order edit form. This seems like a logical approach and is inline with comment #1. However, I'm not clear on the actions api that @bojanz specified, so if anyone has thoughts on that it'd be great too. I think solving this issue will greatly increase the intuitiveness of product displays. Let's make it happen!
Comment #20
bojanz commentedAs I said, forget about the Actions API for now, just make something that works :) I'll try to work on IEF issues this weekend and solve some surrounding problems.
Comment #21
andyg5000I've created a patch that allows you to assign an existing product SKU through the inline entity form. It extends hook_inline_entity_type_info() by adding a new callback 'existing form'. If that callback exists then the module adds a new button for adding an existing variation. Validation makes sure that the SKU is an actual product and restricts duplicate references. I updated the commerce_product entity type in this module, but not the commerce_line_item type.
Comment #22
andyg5000Same as #21, but cleaner patch
Comment #23
philipbe commentedThank you andyg5000!
Patch works for me.
Comment #24
bojanz commentedThis will need a reroll to work with the latest code.
Thanks for the work so far, andyg5000!
Comment #25
mnislamshihan commentedHi andyg5000, could you please make the patch compatible with version 7.x-1.0-beta2 of IEF. I tried to apply the patch over the source of 7.x-1.0-beta2 release and the patch failed with message:
Alternatively, could you please mention the version number of IEF for now, on which the provided patch can be applied??
Comment #26
andyg5000@mnislamshihan that patch was made on this commit http://drupalcode.org/project/inline_entity_form.git/commit/d38db73 . I hope to rewrite the patch on the current HEAD, but I need to have chat with @bojanz before moving further. It will probably be the first of next week before I can post it if someone doesn't beat me to it.
Comment #27
mnislamshihan commentedThanks a lot @andyg5000. It worked this time :-)
Comment #28
JulienF commentedHello there,
Just my two cents but here, I think, would be a good way to go:
A module is on the net (called autocomplete Product Reference Widget but I can't manage to find it on Drupal.org) here is the link to it: http://www.duckzland.com/content/drupal-7-commerce-create-better-product...
This module offers a very nice widget to select existing products and add them to a Display. We even could customize it to only show Products on the upper table when a certain condition is met (like only the products that haven't been referenced yet).
I think a mix in between IEF and this module would be great.
1. Showing the "Adding existing product" Widget by default and then showing the IEF form when an "Add new product" is being pressed.
2. As an option we could even think of integrating IEF with tokens in order to automatically fill some fields with Tokens (configured in the Edit Field page) and hide those fields from the Product Edit page.
I'll personnally need the First point in a project and I'll work on it, if anyone want to join the effort feel free!
For the second point, eventhough I think it would be of great help, I don't need such functionality right now (some values can be automatically filled with rules on the creation of the entity) so I'm not planning on working on it right now.
Cheers,
Comment #29
bojanz commented@JulienF
None of those are tasks for IEF. Feel free to create a new module and explore the UI you describe. As always, 10 users == 10 approaches :)
Comment #30
andyg5000Here's an updated patch that works with the new changes mentioned in #24.
Known items that may need to be addressed:
Comment #31
nelslynn commentedThis is awesome... Thank you andyg!
Here's a suggestion to improve, or maybe I'm missing something...
Comment #32
andyg5000Hey nelslynn,
Thanks for the review and feedback. I think that the first item you mentioned needs to be a separate issue. It's easy to remove the code that shows the form if there are no references, but if the reference is a required field then no validation is done. We'll need to come up with a validation hook to check for entities in the array if it is a required field.
As for the second suggestion, both the add new and attach existing buttons are visible whenever an entity reference is being edited. I'm guessing your second screenshot is supposed to show this, but it must have been cropped too small. From a UI perspective, I don't see that hiding the add and attach buttons would make the widget any more intuitive.
Thanks,
Andy
Comment #33
andyg5000Here's an update to the patch that takes care of the issues I mentioned in #30. It would still be good to run the entityreference submit value through validateAutocompleteInput() so that submissions made without selecting an autocomplete result can still be looked up, but I don't think that's major. I also went ahead and removed the code that draws the add form when there are no entities (#31). We'll need to create another issue to handle validation if it's a required field. This patch also cleans up the attach form and processing functions quite a bit. More reviews please!
Comment #34
joachim commentedMinor things: there's a few code style issues such as missing spaces near 'if' and brackets, and a coddled 'else'. Comments need to end in full stops.
Other things:
This appears to be an element validate callback, so should be described as such. 'Process' means something specific in FormAPI.
This should be moved out to the controller for the Commerce product entity rather than the base module code.
Presumably it's that that's showing the SKU rather than the product title once I click an item in the autocomplete dropdown.
Comment #35
joachim commentedActually, the autocomplete should probably be per-field type, not per entity type.
Currently, the autocomplete isn't working at all for inline nodes with this patch: #1658056: Add node integration.
One more thing: does the bundle dropdown button affect the 'add another' button? Because they are all in one line, it could seem like it does.
Comment #36
joachim commentedThe reason the autocomplete doesn't work for nodes is that the entityref autocomplete path expects an entity ID too, before the actual string to match on:
This is done by _entityreference_autocomplete_validate() being on the autocomplete element.
So definitely one to do by field type.
Comment #37
bojanz commentedThe patch is good enough for now. I'll tweak it myself prior to committing.
Thanks for the review, joachim.
Comment #38
joachim commentedHere's a patch that fixes everything in my last few comments, apart from these:
> This appears to be an element validate callback, so should be described as such. 'Process' means something specific in FormAPI.
On second look, that's a problem in the module prior to this patch ;)
> One more thing: does the bundle dropdown button affect the 'add another' button? Because they are all in one line, it could seem like it does.
I'm not sure what to do about this. Thoughts?
I've had to add a 'field_type' property to inline_entity_form_field_widget_settings_form(), as we need to know the base field type in the various handlers this patch adds.
Comment #39
joachim commentedUpdated patch; there was an undefined var error being produced by my copying and pasting code :/
Comment #40
joachim commentedHad a few thoughts about this, which shouldn't hold this patch up as it's pretty vital, put possible future refinements:
- make the widget for adding existing entities pluggable
- piggyback existing widgets from the field type
(I'm partly motivated here by thoughts on how to port image module's image attach to D7, and for that I always figured a horizontal film-strip of images would be a really nice widget to have for selecting existing images to attach.)
Comment #41
dave reidre #40: That also sounds very similar to what Media is doing with the Media browser widget.
Comment #42
toby53 commentedExcellent job !
Comment #43
dianikol commentedIs the patch from #39 committed to the the dev version or should i apply it? :)
EDIT: The product title is not there after applying the patch. It takes the node's title. Is it possible to save titles for different variations?
Comment #44
andyg5000@dianikol The patch shouldn't cause that. Go to edit for the field under manage fields for your product display node and uncheck "Auto generate the product title"
Comment #45
dianikol commentedYes, I missed that.. Thanks for the patch. It shows two notices though when i try to attach an existing product. But it works pretty nice.
The warning are these:
Notice: Undefined variable: delta in inline_entity_form_attach_entity_form() (line 674 /home/wwwhomep/public_html/drupal/sites/all/modules/inline_entity_form/inline_entity_form.module).
Notice: Undefined variable: delta in inline_entity_form_attach_entity_form() (line 685 /home/wwwhomep/public_html/drupal/sites/all/modules/inline_entity_form/inline_entity_form.module).
Comment #46
brycesenz commentedI can confirm that the patch in 39 is working well for me. I get no notices/warnings though.
Also, the exchange in comments #5-#15 was one of the more amusing things I've seen today.
Comment #47
damienmckennaTested out the patch from #39 with Commerce 1.2 on Drupal 7.14 and it works great - no errors or warnings.
Comment #48
jerryitt commented#39 Patch applies cleanly, No errors or warnings and works as expected.
Comment #49
jherencia commentedRerolled to latest git dev version
Comment #50
jherencia commentedOk, the patch @joachim and others provided didn't work for me, because _entityreference_autocomplete_validate needs the field's settings to have defined match_operator, which is not.
This patch adds the widget setting to define whether the operator is "contains" or "starts with".
Comment #51
jherencia commentedThere is a bug in entity_reference that prevents the possibility to add an existing node in node_add_form, it works ok on node_edit_form.
See #1706664: Autocomplete fails with inline_entity_form.
Comment #52
marcin.wosinek commentedI attach rerolled patch from 39. It works as expected, no issue mentioned in 50 noticed. I'm marking it RTBC; because patch works and future fixes will be easier to develop in another issues. It's also blocker for this issue #1717196: Selecting existing entities - integration for nodes.
Comment #53
bojanz commented@marcin.wosinek
You've uploaded an empty patch.
Comment #54
marcin.wosinek commentedOh. Once again.
Comment #55
jherencia commented@marcin.wosinek: #50 is a rerolled version of #39 patch with a major bug fixed, so I think it's probably better to review it instead of commiting a partial fix.
To see what #50 explains please install a new Drupal installation and add a new field using entity_inline_form widget, it wont't work.
I'm not using this module in a Commerce environment, so that could be the reason why others have not found the same issues I have.
@marcin.wosinek, could you try #50?
I'll change the status so @bojanz or @rszrama could review it.
Comment #56
marcin.wosinek commentedI've tested #50 with clean installation on standard apache + mysql from ubuntu 12.04. I've use case of new node content type referring to articles. As for me #39 and #50 worked the same - in both cases matches where found, and I've manage to save everything. I've checked
_entityreference_autocomplete_validateand have not found any hint in code or doc of requirements mentioned in #50.I believe that there is still work to do on this feature - there are some issues with (#1717196: Selecting existing entities - integration for nodes) when referring nodes; we will probably need some ui for removing entities from list (not deleting entirely); and probably other as well. I just think we can develop solution for this emerging issue in other patches, as here we have 50+ comments here, and it's becoming difficult to track differences between patches.
I attach rerolled patch 50, and interdiff of 50 and 39.
Comment #57
bojanz commented@ marcin.wosinek
I'm fine with committing the current progress, but you've given me a wrong patch again.
Comment #58
marcin.wosinek commentedShame on me. Here is double checked patch.
Comment #59
jherencia commentedThat's #39 it has the same problems I said in #50.
Comment #60
jherencia commentedHere is the rerolled version of #50.
Comment #61
marcin.wosinek commentedBoth patches - #58 & #60 are RTBC.
Comment #62
jherencia commentedThis does not work on nested IEFs, I'm working on a patch right now, in few minutes I'll post the patch.
The reason is that in the autocomplete options IEF gives the parent's options, not the nested ones. This happens because we are giving the parent's ID in autocomplete path.
Comment #63
jherencia commentedComment #64
jherencia commentedComment #65
daniel kulbeNotice: Undefined variable: delta in inline_entity_form_attach_entity_form()
row: 686, 697
Comment #66
Anonymous (not verified) commented#63 works great for me thanks. I don't get any Undefined variable notices either (though a quick inspection of the code shows that I probably should be... I must just have disabling displaying PHP notices).
Daniel - did the patch work for you apart from the Notice? Seems like it's harmless, and would be good to get this committed.
Comment #67
Anonymous (not verified) commentedI just got the same Notice as Daniel, after using the patch for a while. Steps to reproduce:
1. Click edit on a Product Display node
2. Click edit on a variation and then save that variation (no changes necessary)
3. Click "attach existing varation"
4. Click main save button at bottom of page
5. You get validation error: "Variation field is required"
6. Click cancel on "attach existing variation" form
7. Click "attach existing varation"
Comment #68
jherencia commentedOk, let my try to fix this.
Comment #69
jherencia commentedThis should work.
Comment #70
dgastudio commentedusing 1526084-69-am.patch from #69.
trying to search existing entity return popup js error:
Comment #71
maico de jongAttached patch works for me with latest beta4 version. (Beta4 is newer then latest dev)
Comment #72
dgastudio commentedtesting latest patch
curl http://drupal.org/files/inline_entity_form.module.patch | git apply
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10195 100 10195 0 0 10824 0 --:--:-- --:--:-- --:--:-- 13223
:9: trailing whitespace.
'match_operator' => 'CONTAINS',
:17: trailing whitespace.
$element['match_operator'] = array(
:18: trailing whitespace.
'#type' => 'select',
:19: trailing whitespace.
'#title' => t('Autocomplete matching'),
:20: trailing whitespace.
'#default_value' => $settings['match_operator'],
warning: squelched 169 whitespace errors
warning: 174 lines add whitespace errors.
-------------
the patch is applied and works fine! thank you
Comment #73
jherencia commentedAlright, the problem is that the dev version package does match with Git's dev version. My patch works in git branch 7.x-1.x.
Comment #74
forward-media commentedWorks perfekt for me with Beta4!!
Thanks!!!
Comment #75
itsekhmistro commentedWorks fine. I believe the solution should be applied into the Module.
Comment #76
daniel kulbeIt should only be applied when something like this works ...
Comment #77
bojanz commentedWorked on my own version based on the latest patch, and committed it:
http://drupalcode.org/project/inline_entity_form.git/commitdiff/087b72b?...
Changes:
1) The functionality is now optional, disabled by default.
2) Not available at all for line items (since it makes no sense and the line item reference field has no auto complete).
3) Works with entityreference + nodes too.
4) Uses our own autocomplete code, which leads to simpler code, and the match operator actually being used (previously it was ignored for products).
Referenced entities are just unliked if deleted before the parent form is saved.
After the parent form is saved, clicking "Delete" will permanently delete the entity.
This means it's now critical to solve #1617886: Remove entity without deleting. Please give your opinion there.
Thanks to everyone involved!
Comment #79
heyyo commentedIt will be great to have also the possibility to have also checkbox option and not only autocomplete
Comment #80
bojanz commentedPatches welcome.
Comment #81
maxplus commentedYes, great work already!
The ability to use a select list or checkbox to select existing nodes would be great indeed
Comment #82
summit commentedHi, adding to this would hierarchical select (http://drupal.org/project/hierarchical_select) ability be absolutely awesome!
Greetings, Martijn
Comment #83
mihai7221 commentedHi, the last patch doesn't work, it gives me this error:
patching file commerce_line_item.inline_entity_form.inc
Hunk #1 FAILED at 45.
1 out of 1 hunk FAILED -- saving rejects to file commerce_line_item.inline_entity_form.inc.rej
patching file entity.inline_entity_form.inc
Hunk #1 FAILED at 115.
Hunk #2 FAILED at 129.
2 out of 2 hunks FAILED -- saving rejects to file entity.inline_entity_form.inc.rej
patching file inline_entity_form.module
Hunk #1 succeeded at 104 with fuzz 1 (offset 95 lines).
Hunk #2 FAILED at 302.
Hunk #3 FAILED at 319.
Hunk #4 succeeded at 704 with fuzz 1 (offset 230 lines).
Hunk #5 FAILED at 516.
Hunk #6 succeeded at 946 with fuzz 2 (offset 420 lines).
Hunk #7 FAILED at 562.
Hunk #8 FAILED at 708.
Hunk #9 FAILED at 719.
Hunk #10 FAILED at 789.
7 out of 10 hunks FAILED -- saving rejects to file inline_entity_form.module.rej
I applied the patch correctly, in the working directory. Maybe I get this because I use version 1.1 ?
EDIT: Shame on me, this was included in the last version, I didn't looked in the configuration of the field, just a box to check and everything was fine.
Comment #84
bdreispringer commentedwith the latest patch applied together with 7.x-1.5 the autocomplete gave me always
Array(bundletype). (Where bundletype was the node content type)
I had to the autocomplete function here:
So the part in the code looks like
Comment #85
muntjac commentedResetting this to active since the patches break. This would be a good feature.
Comment #86
bojanz commentedAs #77 says, this work was committed on September 17, 2012. I have no idea why you are attempting to apply a patch.
Comment #87
tahiticlic commentedHi,
if no patch is needed, maybe one can tell how to use this module to add an existing entity into Entity Reference field.
My settings :
Module version : 1.5
Field widget : inline entity form - single value
Delete referenced nœuds when the parent entity is deleted : unchecked
Override labels : unchecked
Behavior :
When editing the main node containing the entity reference field, this field is directly replaced by a form to create a new entity. No way to add an existing one.
What am I missing ?
[Edit] : I should select multiple values, which is a bit confusing since we can have a multiple values widget on a single value field...
Comment #88
kcannick commented@Tahiticlic and anyone who stumbles on this post after the fact...
Once the widget is changed to inline entity editor, you will have an option in the field properties to ADD EXISTING PRODUCTS.
Comment #89
tahiticlic commented@Kcannick : Yes, and as I mentionned, this is only true if you select "Inline entity form : Multiple Values", even for a single value field. That is the confusing point.
Comment #90
njbarrett commentedIt wasn't obvious to me, but I needed to change the widget and also change the field settings and check the box that says allow users to select existing entities.
Comment #91
fishfree commented@tahiticlic: I was bewildered with the same question. But at last, I found we could use the "Inline entity form : Multiple Values" widget even for a single-valued field! You can have a try!
Comment #92
nkostop commentedI would like to ask if it is possible to bulk add existing products. Maybe with a select list instead of autocomplete.
Thanks!
Comment #93
colepacak commentedthanks, @fishfrree.