Closed (fixed)
Project:
Inline Entity Form
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Jan 2013 at 11:22 UTC
Updated:
24 Aug 2017 at 01:49 UTC
Jump to comment: Most recent
Comments
Comment #1
bojanz commentedYou can replace the controller for nodes like shown in http://drupal.org/node/1521274#comment-6738984 and override the labels() method.
Your form alter looks fine at a glance so I don't know why it's failing, you'll have to debug it.
Comment #2
technotim2010 commentedHi
I have the same issue as MXT and tried more or less the same solution using hook_form_alter
Note I used = on line 4 rather than == (which is a logical comparison operator is it not?) and hey ho I get success the button now reads "Add Runner Times"
I hope that helps someone else esp MXT
Tim
Comment #3
mxtYes Tim: you discovered the error: thank you!
Can I ask you if you also have successfully altered the "save node" button WITHIN the ajax loaded referenced entity form? dpm($form) does not work with ajax in the way...
Comment #4
mxtOk, I've got it, so, to resume:
MXT
Comment #5
technotim2010 commentedHi
So to sum up just for those seeking this answer and to make it nice and simple for them (I recall too much head scratching trying to incorporate a solution only partly listed)
If you are adding multiple values of another content type using entity reference and entity inline form it adds the "add node" button/link and this we can override with the hook_form_alter using the code
where your_field_name is the name of the field calling the inline entity form
This usually needs pairing with overriding the "Save Node" button/link as well so again in the same hook_form_alter function we add
The produced form still has a title of "add new node" so this needs overriding as well, the code (in the same hook_form_alter does this
I have no need to, but a cursory look using devel page array revealed no way to override the resulting form field names etc (but I may be wrong over to someone else)
So to put this all together nicely
I hope that helps someone else using this module.
Comment #6
timwoodThank you TechnoTim2010 and MXT for this public discussion and awesome example solution. It was just in time for what we needed!
Just to clarify one thing...the form you need to alter is the parent entity form, not each referenced node type's form. This was not obvious (at least to me) in the examples.
Comment #7
technotim2010 commentedTim
Yes the parent Entity form
Tim
(If only the middle text was palindromic this message would look really good)
Comment #8
demon326 commentedI'm very sorry to bump this, i came across this post because its the exact same thing i need, but it won't work with me?
I have the following code in my custom module, named 'ashladan'
but it keeps using the node terms, instead of this?
Comment #9
timwooddemon326,
I think you need to use underscores not dashes in the "case" line. So:
Comment #10
demon326 commentedThank you Tim! I knew it had to be something simple, but i never thought it would be this simple!
Comment #11
rajab natshahThanks this worked ..
Hope to have this as an option in the Inline Entity Field widget.
To use the Title of the Field or custom text as 'Add new Node' , 'Save Node'.
Comment #13
timwoodSorry to revive this thread, but does anyone know how to identify the "Save node" button when editing a referenced node? The ID on the submit button is "edit-field-myfieldname-und-entities-0-form-actions-ief-edit-save". But I cannot figure out how to translate this to the field override inside my form_alter hook. This is using the IEF multiple widget.
Thanks!
Comment #14
technotim2010 commentedHi
Now I haven't tried this so apologies if it may be wrong and break, but taking my generic code earlier and changing "ief_add_save" to "ief_edit_save" should work then edit the label #value to whatever you require. (sorry have no access to the dev server with the dev site using IEF as at work)
so
Comment #15
technotim2010 commentedHi
Now I haven't tried this so apologies if it may be wrong and break, but taking my generic code earlier and changing "ief_add_save" to "ief_edit_save" should work then edit the label #value to whatever you require. (sorry have no access to the dev server with the dev site using IEF as at work)
so
Comment #16
timwoodTim,
Thanks for the reply. That was the exact code I tried and it doesn't work. My co-worker did some investigating and came up with the code below that uses a different hook, which I'm going to test this morning. Here is what my co-worker (smoovb) suggested:
Comment #17
timwoodSome funny characters came through in that last code that appears when you copy/paste. Here is the code sans characters:
Comment #18
timwoodYup. This worked. This code changes this particular form button, globally, for all entity types. Replaces @type, normally entity, with bundle. Not sure how this will affect a Drupal Commerce site or others using IEF to reference other entity types. Because it applies global, I added the code to a "helper" module.
Comment #19
operations commentedThanks all! Very helpful..
Comment #20
apoc1 commentedI didn't get that last one working. Should something been changed in the code of #17?
Comment #21
-enzo- commentedI did a variation for patch recommeded at #1880850-17: How to change the "node add $type" submit button text? to handle add and edit form
Comment #21.0
-enzo- commentedMissing }
Comment #22
sjhuskey commentedIn case anyone is still struggling with this issue, I'd like to save you the time that I spent trying to implement the solutions above. There's a way to change the text of the submit button text in entity reference fields without having to write a module:
Comment #23
nicolas bouteille commentedThat is EXACTLY what I was looking for...! I came here to actually suggest we would add such a feature... This module is AWESOME and sjhuskey thanks so much for the tip!
This made my day and I sure will dance about it right now :)
Comment #24
milos.kroulik commentedI can confirm, that tip in #21 works fine.
Comment #25
Karim EL Shazly commentedThanks :) #22
Comment #26
ahoms commented#22 is the right answer, there's no need for extra coding!
Comment #27
neighbors commentedWow #22, that was awesome! I realize that was many years ago, but that nugget saved me a lot of digging/coding. Thanks again :)