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.
For 2 days I'm trying to list all the fields of the Entity Reference field. as descried in the attached photo but I can not ...
please inform how do I change the fields that will be listed in the form.
I want to hide the status field and add other 2 fields to the list...
I chose render entity in manage display field .... I check the teaser.... I google the issue...
no solution
Comments
Comment #1
ashrafabedUse hook_inline_entity_form_table_fields_alter() in a custom module to add/remove fields
For example, this is how I removed the title field and added the body field to the content type 'my_content_type':
Comment #2
msh2050 CreditAttribution: msh2050 commentedDear ashabed thanks a lot for your replay it really great...
honestly I'm coming from Vb.net to Drupal (witch depend on PHP )
I start using drupal from 2 weeks only.
the above code is very clear and easy to modify as per my needs...
I learn about hook and module customization as per the below video"
hook form alter
then I just apply your code with changing the field name "please find the attached file of the custom module"
with best regard
Comment #3
bojanz CreditAttribution: bojanz commentedComment #4
msh2050 CreditAttribution: msh2050 commentedSorry bojanz
I forget to write that this did not solve the problem and make no change in the form
to dive more details:
I have a content of tender with a reference field to tender_details content "witch contain item and required quantity ....etc...
So I make a custom module "as in attachment" enabled then add ashabed code with changing the My content type field with tender_detail and is_my_content_type with is_tender_details...
but I did not get any changes in the form neither the title removed nor the new field appear..
Please help
Comment #5
msh2050 CreditAttribution: msh2050 commentedI change the status, hope I can find the solution but I feel I'm closer to fix...
I try to use the modules and codes in the Investigate a UI for configuring table columns (which fields and in what order) post 21
the I edit it with post 25 to use for all content type..
it show very useful tab to edit the display field and controls but unfortunately their may be some error since I cannot edit or add any content that use inline entity form...
I write more details there https://drupal.org/node/1521274#comment-7880303
Comment #6
ashrafabedmsh2050, I opened your zip file and noticed one big issue:
You have to change 'MY_CUSTOM_MODULE to the machine name of your module.
So, your Costum_Inline_intity_form.module file should be something like:
Try it out and let me know what you get.
Comment #7
msh2050 CreditAttribution: msh2050 commentedDear ashabed
Many Many thanks It work for me and I really enjoying changing the fields...
I made some extra changes just for testing ...
I hide both title and status...(As in attachment)
but the format of the decimal field is not same the format that I configured in field stetting and in display management(how I can make the scale = 0 rather that currently(witch is 2)
below is the final code in case some one need it:
Comment #8
ashrafabedMaybe this should be a new issue... but you said "(how I can make the scale = 0 rather that currently(witch is 2)"..and your code says
Before looking into it, could it simply be changing 'scale' => 2, to 'scale' => 0,?
Comment #9
msh2050 CreditAttribution: msh2050 commentedyes it work greatly... thanks a lot for your cooperation ....
Comment #11
baddysonjaThis is great and it works goot. I only have a problem with the formatting of f.x. an integer field. I have configured the field to be shown: 1.300,45 but I can't get the field to show this format. It only shows: 1 300.45
Any ideas?
Comment #12
Makku01 CreditAttribution: Makku01 commenteddid you accomplish this baddysonja?
Comment #13
argiepiano CreditAttribution: argiepiano commentedThank you so much for this. I have a avery basic understanding of PHP, but this was easy to implement
Comment #14
drewpal3 CreditAttribution: drewpal3 commentedThis works well. I was able to changed the scale.
Comment #15
operawong CreditAttribution: operawong commentedThe code doesn't work for me,
In my project , there are two node types , one is 'people' ,one is 'case' ,
I wish when user add node 'case' can use Inline Entity Form to add node 'people',
I set all 'people' fields to Required, but it seem doesn't work,
'title' and 'status' field still was shown.
here is my Costum_Inline_intity_form.module
Comment #16
argiepiano CreditAttribution: argiepiano commented@operawong: there could be many reasons why it is not working. As a first step, I would verify that the hook is actually being invoked. Add a line like
set_drupal_message('I made it here!', 'status');
right before$is_tender_detail = FALSE;
, save the module, refresh your cache and visit the page that has the inline entity form. If you don't see a status message "I made it here!" then you know the hook is not being invoked. That's a good start.If you find out the hook is being invoked, then I would make sure to check that the name of the bundle ('tender_detail') actually matches the name of YOUR bundle, and that the names of the fields you are changing with
unset();
match the names of the fields in your bundle.Alternatively you can install the module Devel (https://www.drupal.org/project/devel) and insert the lines
dpm($context);
anddpm$(fields)
instead of theset_drupal_message()
above to inspect the contents of those two variables, which should allow you to match the names of the bundle and fields.Always clear cache.
I hope this helps.
Comment #17
argiepiano CreditAttribution: argiepiano commented@operawong, one more thing. Be sure the name of your module ("Costum_ ...) uses only lowercase letters. It must match the first part of the name of your hook.
Comment #18
operawong CreditAttribution: operawong commentedThanks argiepiano , but I didn't see the message 'I made it here!'
here is part of my code
Comment #19
operawong CreditAttribution: operawong commentedComment #20
argiepiano CreditAttribution: argiepiano commented@operawong: since the message was never displayed, that's an indication that the hook implementation was never invoked. This may be most likely to a mistake in how you created the module. The file you attached must be in a folder inside the sites/all/modules folder. The folder must be called EXACTLY like the first part of the hook (costum_inline_intity_form). The module must be called
costum_inline_intity_form.module
. And the folder must contain an info file calledcostum_inline_intity_form.info
with specific code inside. If this is the first module you create I'd suggest careful attention to this tutorial: https://www.drupal.org/developing/modules/7 (by the way, if you did all this, have you enabled the module you created?)If you did follow those steps carefully, you should see the "I made it here!" message every time drupal renders an Inline Entity Form.
Comment #21
operawong CreditAttribution: operawong commentedI did it and enable the module
Comment #22
kopeboy CreditAttribution: kopeboy commentedI created a module like the examples and could hide (unset) status and sku fields from the table, but I couldn't hide the image field. Is there something more to be done in case of images?
(I can see commerce_product.inline_entity_form.inc code is a bit different there because you have to detect the image field name without knowing it..)
I only have 1 image field, machine name 'product_image', how to unset it?
unset($fields['product_image']);
is not hiding it from the tableComment #23
kopeboy CreditAttribution: kopeboy commentedI ended up deleting the lines 47 to 98 of the commerce_product.inline_entity_form.inc file but still an horrible solution.
I also need to show a term reference field (the title of the chosen term) in the table, any help on how to do this?
I tried this (not working)
Thanks
Comment #24
jweirather CreditAttribution: jweirather commentedPosting this related how-to thread for hiding/modifying IEF fields on standard user forms: https://www.drupal.org/node/2497289
Comment #25
Dr.Osd CreditAttribution: Dr.Osd commentedThanks all for solution!
Additional question: how to show Inline entity form listed fields only if they not empty?
Comment #26
mnico CreditAttribution: mnico as a volunteer and at TIFON commentedHi, I built a module to help me with this, using view mode. Maybe this can help you
https://www.drupal.org/project/ief_table_view_mode
This still in dev but it works for me well right now
Comment #27
kopeboy CreditAttribution: kopeboy commentedwow mnico, that is really useful!
Any chance we could do something with the node add/edit form as well?
Comment #28
francescosciamanna CreditAttribution: francescosciamanna commentedThank you mnico!!!
Comment #29
johnhanley CreditAttribution: johnhanley as a volunteer commented@mnico, I use to override the IEF table theme in code, but now with Inline Entity Form Table View Mode it's a breeze. The module has a small footprint too. Well done!
Comment #30
johnhanley CreditAttribution: johnhanley as a volunteer commentedRevisiting this issue in Drupal 8.
I'm adding a taxonomy term to the output of an inline entity table via hook_inline_entity_form_table_fields_alter. The term is outputted as a link, which doesn't make sense in this context. I've hunted high and low, but I can't seem to find an example of how to output the term value as plain text. I found a reference to a 'formatter' attribute for Drupal 7, but I can't find any examples of how to implement it Drupal 8.
Can someone give me a nudge? I figure the answer will be useful to others.
Comment #31
bat2018 CreditAttribution: bat2018 commentedHi John Hanley,
the solution for me is:
Ciao!
Comment #32
johnhanley CreditAttribution: johnhanley as a volunteer commentedThanks @bat2018. Noted for future reference!
Comment #33
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedClosing as this support request has been answered.