Problem/Motivation
If I add a field of type text_long using hook_entity_base_field_info(), and I use the text_textarea field widget, then the value of rows is set to the string '5' by default. The resulting config object core.entity_form_display... fails validation since text.schema.yml declares that rows should be an integer.
Adding a field through the UI does not have this problem. I have not tracked down why.
Steps to reproduce
Implement hook_entity_base_field_info() in a custom module and define a field as in the previous section.
Proposed resolution
In the parent class Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextareaWidget, change the default value for rows from the string '5' to the integer 5.
Remaining tasks
User interface changes
None
Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
N/A
Issue fork drupal-3464575
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3464575-textarea-rows-default
changes, plain diff MR !8977
Comments
Comment #2
benjifisherWe could also fix the problem in the
textmodule: either changetext.schema.ymlor overridedefaultSettings()in the child classDrupal\text\Plugin\Field\FieldWidget\TextareaWidget.Comment #4
benjifisherThe MR has the proposed resolution. This is my entry in the contest for this year's smallest change.
I will set the status to NW, not NR, because this bug fix still needs a test.
Comment #5
prashant.c@benjifisher
I found an existing test for this field type here: StringFieldTest.
https://api.drupal.org/api/drupal/core%21modules%21field%21tests%21src%2...
Do you think this test will suffice as is, or do we need to modify it or create an entirely new one? Please advise.
Comment #6
benjifisher@Prashant.c:
Thanks for taking a look at this issue!
That test class is in the
fieldmodule, and it does not enable thetextmodule, so I do not think that is the right place for it.Also, we need a test that fails without the change I made in the MR. All current tests are passing, so we need to add a new test, once we decide on where to add it.
I think
Drupal\Tests\text\Functional\TextFieldTestis the right place.Before doing too much work, check what I said just above "Steps to reproduce": if you add the field from the UI, then you do not run into this problem. If I was right, then you will need to write a test module that implements
hook_entity_base_field_info(). I can help with that if you want.I am not sure how to test for config validation. But I think we should do that, and not just check the configuration. That is why I think this should be a functional test.
Comment #7
benjifisherI tried to reproduce this issue starting with a fresh install of Drupal core, and I could not.
There must be something else on my site that is causing this odd behavior.
I am postponing this issue now. I hope I will have time next week to look into it some more.
Comment #8
smustgrave commented@benjifisher wonder if you've hit this issue again?
Comment #9
benjifisherI put in some sort of work-around for my day job, but I have not had a chance to figure out where the problem is.
If this issue stays open, then I am more likely to make time to look at it eventually, but I will not complain if you close it as "cannot reproduce".
Comment #11
smustgrave commentedYea I haven't been able to replicate, using configuration inspector. Can always re-open though.
Made sure benjifisher got credit for all the work he did here.