I've installed the module and I've left the config and permission to what they are out of the box. I've updated a HTML-enabled text area field that sits on a Paragraphs bundle to "Limit allowed text formats" and in the "Allowed formats" field, I've selected only one format, a text format we created called "Full HTML No Editor". (We have 3 others.) When I go to add a node and add the Paragraphs bundle with the field in question, none of the settings take affect -- the text format selector is there with the default format ("Basic HTML") selected instead of "Full HTML No Editor" and the "About text formats" link is still there.
Comment | File | Size | Author |
---|---|---|---|
#45 | better_formats_paragraphs-2754029-45.patch | 6.46 KB | oknate |
| |||
#42 | interdiff-37-42.txt | 690 bytes | oknate |
#42 | better_formats_paragraphs-2754029-42.patch | 4.78 KB | oknate |
| |||
#37 | better_formats_paragraphs-2754029-37.patch | 4.73 KB | stefanos.petrakis@gmail.com |
|
Comments
Comment #2
dom18fr CreditAttribution: dom18fr as a volunteer commentedI experienced the same issue using paragraphs module.
See my patch.
Comment #3
dom18fr CreditAttribution: dom18fr as a volunteer commentedComment #4
Lukas von BlarerLooks good!
Comment #5
rolfmeijer CreditAttribution: rolfmeijer at Dutch Open Projects commentedSome patches cannot be applied together, or make other patches obsolete.
The patch from #2 seems to make #2735633: Text fields empty after saving a form #6 obsolete, as it fixes that issue as well.
On the other hand, it cannot be combined with the patch from #2728477: 500 error on add taxonomy term form submit #2, so I combined those two in a new combined patch. I hope it still makes sense.
A new (dev-)release would be highly appreciated, to clean up all these conflicting patches.
Comment #7
Lukas von BlarerThis is not how we handle patches on d.o. Since this still applies, this stays RTBC. If this not the case anymore, we have to work on this.
Comment #9
rolfmeijer CreditAttribution: rolfmeijer at Dutch Open Projects commentedI see what happened, annoying, sorry about that.
Comment #10
Lukas von Blarer@rolfmeijer no worries. Do you want to try fixing the tests so we can get this committed?
Comment #11
rolfmeijer CreditAttribution: rolfmeijer at Dutch Open Projects commentedI already had a go, but with no success yet. But I will absolutely try again.
Comment #12
ahebrank CreditAttribution: ahebrank at NewCity commentedUpdating the patch in #2 to apply to the current field widget names.
Comment #13
Daniel Korte#12 is working for me. Thanks!
Comment #14
Daniel KorteI found a bug where this patch throws an error when a block entity doesn't have the method
Drupal\block_content\Entity\BlockContent::getTargetEntityTypeId()
when managing Custom Block fields which use theDrupal\field_ui\Form\FieldConfigEditForm
. I patched #12 to check if the entity exists and it has thegetEntityTypeId()
method since the first block of the if statement works fine in this scenario. This probably isn't the most elegant solution, but I thought I'd share the patch as a crude fix to the bug.Comment #15
ahebrank CreditAttribution: ahebrank at NewCity commentedOops, bug in 14 is my mistake, shouldn't have messed with the config edit form. Here's a slimmed down version of 12 that should avoid that.
Comment #16
ohthehugemanatee CreditAttribution: ohthehugemanatee at Amazee Labs commentedWorks for me.
Comment #17
ohthehugemanatee CreditAttribution: ohthehugemanatee at Amazee Labs commentedComment #19
Sutharsan CreditAttribution: Sutharsan commented+1 RTBC
Code makes sense. Works as advertised.
Comment #20
John Pitcairn CreditAttribution: John Pitcairn commented+1 RTBC. Patch works for me, thanks.
Comment #21
kevinquillen CreditAttribution: kevinquillen at Velir commented+1 RTBC - definitely fixes the issue.
Comment #22
dddbbb CreditAttribution: dddbbb as a volunteer commented+1 RTBC. Patch in #15 fixes the issue for me too.
Comment #23
RicardoPeters CreditAttribution: RicardoPeters as a volunteer commented+1 RTBC Patch from #15 is working as expected
Comment #24
rwam CreditAttribution: rwam commented#15 works for me too. Great work.
Comment #25
kmajzlik CreditAttribution: kmajzlik at Ciklum Western Europe for BurdaForward commentedNot working for me :( I am getting error:Notice: Undefined index: #entity in better_formats_filter_process_format() (line 70 of /.../docroot/modules/contrib/better_formats/better_formats.module).
Error: Call to a member function getEntityTypeId() on null in better_formats_filter_process_format() (line 71 of /.../docroot/modules/contrib/better_formats/better_formats.module)
Notice: using Drupal 8.3.0-rc2
Sorry, looks like RTBC now, i didnt cleared cache after applying patch.
Comment #26
stevieb CreditAttribution: stevieb commentedJust to confirm the patch in #15 is working for me
Comment #27
rwam CreditAttribution: rwam commentedI found another bug with patch #15. It's similar to #14 and occurs, if the element has no key
$element['#entity']
For further informations have a look at https://www.drupal.org/node/2862994Attached you can find an updated patch to handle this.
Comment #28
mhavelant CreditAttribution: mhavelant at Brainsum for Tieto commented+1 RTBC Patch from #27 is working great.
Comment #29
kiwimind CreditAttribution: kiwimind at Investis Digital commentedPrior to applying the patch in #27 I had the same issue with all formats showing, regardless of setting, when being used in paragraphs.
After applying the patch only the formats selected show, or are removed entirely when only a single one is selected.
Thanks, moving to RTBC.
Comment #30
GrienauerPatch #27 also works on my side.
Thx!
Comment #31
HaloFX CreditAttribution: HaloFX commented+1 RTBC
Patch #27 works for me on core 8.4.2.
Thank you!
Comment #32
oknateI found a related bug, it's additionally failing inside of entity browser forms:
https://www.drupal.org/project/better_formats/issues/2948527
Comment #33
oknateHere's a slightly altered patch that removes the instance check on the formObject. I found a related bug where it was failing this instance check.
It seems when testing if it's an instance of a content entity form it fails on forms that import content entity forms, such as inline entity form, or entity browser forms.
I don't think this instance check is necessary, since we're earlier setting $element['#entity'] and $element['#field_name'].
Comment #35
oknateIt looks like the namespace of FilterFormatAccessTest has changed, this patch updates patch 33 with the new namespace.
Comment #36
oknateI still found a situation, where on a new entity within an inline entity form within an entity browser that allows adding new entities, it wasn't firing because $element['#entity'] wasn't set.
This is problematic:
as inline entity forms and entity embed forms, etc don't use the entity from the field definition.
This patch moves much of the configuration from better_formats_filter_process_format and moves it to better_formats_element_info_alter.
This reduces the amount of code a bit and I think makes it easier to understand what is going on. I have tested this on fieldconfig pages, on non-inline entity form fields, inline entity field forms and entity_browser forms.
By removing this:
$entity = $form_state->getFormObject()->getEntity();
Where you're determining the entity from the form object
and replacing it with the entity from the field definition,
$entity = $context['items']->getEntity();
it will remove the risk of the wrong entity being referenced.
Comment #37
stefanos.petrakis@gmail.comThanks for the latest patch (#36), it did solve the Paragraphs issue, but introduced - unexpectedly - a different one.
The call to
FieldDefinitionInterface::getDefaultValue
returns a nested array. The value returned byarray_shift($default_values);
in the latest patch returns an array that looks like this:As a result, any subsequent access to
$element['#better_formats']['default_value']
will not work as expected, since a string literal is expected (and not an array object).The provided patch solves this issue, modifying the previous patch minimally (check interdiff).
Comment #38
oknatepatch #37 is causing a warning:
I think this line needs to be broken up so a variable is passed into array_shift, since it takes variables passed by reference:
$default_value = array_shift($field_definition->getDefaultValue($entity));
Comment #39
oknateThanks for the latest patch (#37), I have updated it slightly to fix the notice mentioned above.
Comment #40
oknateSorry I noticed one issue with my last patch (#39), where I wasn't setting $element['#better_formats']['default_value'] = NULL, but rather a $default_value variable that doesn't exist yet.
Comment #41
stefanos.petrakis@gmail.comUr right about the warning, my bad.
Looking at the interdiff, I would like to point out that:
if
blocks, especially nested ones are less readable, I would stick to sth more 'flat' like #37.array_shift()
would offer a better approach, even if it adds an extra step.Comment #42
oknateOk, based on the feedback in #41, I've changed it back to closer to 37, but fixing the warning.
Comment #43
legolasboThe patch works for my project and I could only find some nitpicks, but nothing blocking so RTBC on my end.
This should either be just the "Implements hook_field_widget_form_alter()." or fully describe the variables.
Returning early would remove some levels of indentation and improve readability.
e.g.:
This variable name would be more readable if it were named after what it is. i.e.
$better_formats_settings
or since we're allowed to camelcase now$betterFormatsSettings
Nitpick: Some extraneous whitespace here.
Comment #44
legolasboJust hiding some files.
Comment #45
oknateHere's a patch updated based on the feedback in #43.
Comment #46
oknateComment #47
legolasboLooks good to me :)
Comment #48
Chris Burge CreditAttribution: Chris Burge commentedThanks for working on this issue. I can confirm #45 corrects the issue.
Comment #49
legolasboHopefully this can be committed soon.
Comment #51
dragonwize CreditAttribution: dragonwize commentedCommitted. Thanks to everyone.