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.
Hello,
When a CER fields corresponding field is inside an Inline Entity Form, users would probably not want to display that field. I wrote a small sub-module that exposes an option to hide right hand CER fields when inside an Inline Entity Form (no reason for the fields to be displayed at all IMO, but an option is less intrusive).
//Josef
Comment | File | Size | Author |
---|---|---|---|
#35 | cer-hide-inside-inline-entity-form-2240371-35.patch | 6.9 KB | monya |
#31 | cer-2240371-ief-support-31.patch | 8.06 KB | attisan |
#23 | cer-2240371-ief-support-23.patch | 6.77 KB | phenaproxima |
#12 | cer-hide-inside-inline-entity-form-2240371-12.patch | 6.47 KB | monya |
#8 | cer-ief-2240371-unexpected-char.patch | 829 bytes | jgullstr |
Comments
Comment #1
jgullstr CreditAttribution: jgullstr commentedThe patch.
Comment #2
jgullstr CreditAttribution: jgullstr commentedMarked #2176957: Hide corresponding entity reference field in inline entity form as duplicate of this issue.
Comment #3
phenaproximaWow! Thanks @jgullstr. This is a really neat idea. I wouldn't mind committing this into the main CER bundle once it's been reviewed and tested by others.
Comment #4
jgullstr CreditAttribution: jgullstr commentedClarified title.
Comment #5
phenaproximaLooking at the code, I have a question -- am I correct that this only supports hiding Entity Reference fields, but not other field types that CER supports? If so, that might be something to consider adding.
EDIT: One way to implement that is to set a no_ief flag on certain field instances in hook_cer_fields_alter(), then use that to hide those instances in IEF. That way you would instantly get support for every type of field that CER deals with.
Comment #6
jgullstr CreditAttribution: jgullstr commentedYes you are correct. This is just a quick solution needed for a client project. I imposed this restriction mainly due to convenience, not having to worry about other field types. It could be removed altogether adding a slight overhead. I'll check this out and get back in a bit.
Comment #7
jgullstr CreditAttribution: jgullstr commentedHere's one attempt at making it field type agnostic. I'm not 100% sure I'm using left/right correctly and that CerField will always be available in this context, but I consider this done from my end. If you or someone else wishes to further improve it, feel free to do so.
//Josef
Comment #8
jgullstr CreditAttribution: jgullstr commentedI see this got commited. You have a mysterious "s" at #71.
Comment #9
phenaproximaI committed it by accident a while ago...it needs to be updated to support the alpha7 API.
Comment #10
MrSchoolcraft CreditAttribution: MrSchoolcraft commentedWhen I have this module (extension) enabled, I cannot edit an entity reference field because I get an error that the _cer_filter_presets($filter) function is not defined.
I am using the alpha7 version. Is there anything I need to do to make it able to use this function? I cannot find its definition anywhere in the CER module.
Comment #11
jgullstr CreditAttribution: jgullstr commentedThis is broken for current versions.
Comment #12
monya CreditAttribution: monya commentedI changed module for the current version, but not a test well
Comment #13
adam1 CreditAttribution: adam1 commentedSince in the latest alpha-release there is this bug in CER inline entity form, i would be so glad if someone could change the patch in order to work with the latest dev version of CER. Thanks!
Comment #14
jgullstr CreditAttribution: jgullstr commentedIf no one else fixes this before, I'll rewrite this when a hard release of 3.x (or at least an API freeze) is available.
Comment #15
phenaproxima@adam1: The typo has been fixed in the latest dev. If you're using alpha7, apply this patch:
https://www.drupal.org/files/issues/cer_ief_typo.patch
Comment #16
jgullstr CreditAttribution: jgullstr commentedThe patch is similar to #8 in this thread. Keep in mind that cer_ief does not work at all with versions > alpha5, IIRC.
Comment #17
lucyp CreditAttribution: lucyp commentedHi all, since I am waiting for this feature, I discovered a different way to hide an entity reference field in an IEF. I just wanted to pass this info along in case others are also seeking a solution.
I used the module Hidden Field Widgets https://www.drupal.org/project/hidden_field
Then for that module I applied a couple of patches to allow it to work with entity reference fields.
https://www.drupal.org/node/1821008
https://www.drupal.org/node/2229955
There may be other (better) ways to do it but for me this is working so I am happy.
Meanwhile I'll be glad when this is a regular feature of CER. Thanks to everyone working on the CER module. I really appreciate it.
Comment #18
phenaproximaOK! I did some work on cer_ief and made it use the alpha7 API (i.e., the CerPresetFinder class). I have not tested this at all, but if it works for people here I will promptly commit it to 7.x-3.x.
Comment #19
gdebilde CreditAttribution: gdebilde commentedAny update on this issue ?
Comment #20
phenaproxima@gdebilde: Try the above patch (#18) against the alpha7 version of CER. All it needs is to be tested by the community, and if it works for a few people I will commit it and this long-standing issue will be fixed. ;-)
Comment #21
yasin-ali CreditAttribution: yasin-ali commentedPatch(#18) against alpha7 :: blows up when i click "add new node"... from the log...
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_cer_left0.cer_left_value' in 'where clause': SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {field_data_cer_left} field_data_cer_left0 INNER JOIN {field_data_cer_enabled} field_data_cer_enabled1 ON field_data_cer_enabled1.entity_type = field_data_cer_left0.entity_type AND field_data_cer_enabled1.entity_id = field_data_cer_left0.entity_id WHERE (field_data_cer_left0.cer_left_value LIKE
Comment #22
lucas.constantino CreditAttribution: lucas.constantino commentedFor anyone interested, I have a working solution made within a custom module. Please, not that I've not tried it as hard as I should, and just want to help anyone who needs this feature right now.
I do not have the time right now to look into the patch provided by phenaproxima, but as I've made this solution of mine long ago I believe I can make a new patch based on my previous experience on CER and using phenaproxima's code. I'll try to help as soon as I can ;)
Comment #23
phenaproximaThis should fix the error in #21. (This patch replaces #18.) Sorry about that!
Comment #24
lucas.constantino CreditAttribution: lucas.constantino commentedNice! I'll try to turn off my custom module and apply your patches when I have the time. Thanks ;)
Comment #25
Khalor CreditAttribution: Khalor commentedThe patch in #23 doesn't seem to work (no errors, just doesn't remove the field after selecting 'Hide corresponding entity reference field(s) on form.'). The custom module in #22 does work.
Comment #26
BoobaaArrived here from #2332457: function _cer_filter_presets() is undefined and I can confirm that:
I can't say anything about the code in #22 as I haven't tried it.
Comment #27
funkylaundry CreditAttribution: funkylaundry as a volunteer commentedJust for the record I managed to get it to work by applying the patch suggested by @phenaproxima in #23
Comment #28
NancyDruSee also #2502551: Don't display target field in node edit
Comment #29
trumanru CreditAttribution: trumanru commentedThe patch #23 doesn't work in CER.
I've being installed the CER 7.x-3.x-dev and tried to edit the IEF entityreference field wich is correctly linked by a CER preset with another entityreference field and I've got the error:
Fatal error: Call to undefined function _cer_filter_presets() in bla-bla-bla/sites/all/modules/cer/extensions/cer_ief/cer_ief.module on line 22
It's true. The text '_cer_filter_presets()' couldn't be found in all other files of modules/cer/* (sub)directories (except in the cer_ief.module file - twice).
Comment #30
NWOM CreditAttribution: NWOM commented#23 sadly doesn't work for me either.
Comment #31
attisanimplemented all present ideas (thx to lucas.constantino and phenaproxima) into one patch. this one works great for me.
hope it helps.
Comment #32
RAFA3L CreditAttribution: RAFA3L commentedThis module work too Field extra widgets
Comment #33
shi99 CreditAttribution: shi99 commentedHi,
Patch in #23 worked for me with the latest dev.
Thanks
Comment #34
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedEdit:
This is not a problem with the patch but the cer_ief module itself. There is no 'function _cer_filter_presets'.
_cer_filter_presets does not exist anywhere in the 3.x version of the module. It might be available in 2.x
Comment #35
monya CreditAttribution: monya as a volunteer commentedI fixed problems with patch #23. With this patch we can hide fields in inline_entity_form_single widget too. And also i have changed logic of hiding fields.
Comment #36
delacosta456 CreditAttribution: delacosta456 commentedhi
i am facing similar issue in the CER module that didn't have permission settings to hide the checkbox "Synchronize with.." in a form (not in the display).
I tried install the field permission module , but it has an incompatibility.
Comment #37
P2790 CreditAttribution: P2790 commented@monya thanks for the fixed patch, very helpful
Comment #38
P2790 CreditAttribution: P2790 commentedComment #51
puddyglumpatch #35 worked for me. hoping this can be committed.
Comment #53
phenaproximaReviewed and I think it makes sense. Committed and pushed to 7.x-3.x. Thank you!