I am not able to add additional taxonomy terms (entity reference) even though the field setting is Unlimited. When I click "Add another item" nothing happens, but in the logs it shows:
Recoverable fatal error: Argument 1 passed to Drupal\Core\Form\FormState::setError() must be of the type array, null given, called in /Users/fred/vhosts/ddclab/core/lib/Drupal/Core/Field/WidgetBase.php on line 446 and defined in Drupal\Core\Form\FormState->setError() (line 1156 of /Users/fred/vhosts/ddclab/core/lib/Drupal/Core/Form/FormState.php).
This is the code if I click Location in the log detail:
[{"command":"add_css","data":"\u003Clink rel=\u0022stylesheet\u0022 href=\u0022http:\/\/ddclab:8888\/sites\/default\/files\/css\/css_WoUSDQq02piOhfQKmkZkre5BurnnMpHpdP6QO8aYdt8.css?o0t394\u0022 media=\u0022all\u0022 \/\u003E\n"},{"command":"insert","method":"replaceWith","selector":null,"data":"\n \u003Cdiv role=\u0022contentinfo\u0022 aria-label=\u0022Error message\u0022 class=\u0022messages messages--error\u0022\u003E\n \u003Cdiv role=\u0022alert\u0022\u003E\n \u003Ch2 class=\u0022visually-hidden\u0022\u003EError message\u003C\/h2\u003E\n An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (32 MB) that this server supports.\n \u003C\/div\u003E\n \u003C\/div\u003E\n \n","settings":null}]
I only have one module installed: devel. I'm using the default theme Bartik with no changes.
I hope this helps.
| Comment | File | Size | Author |
|---|---|---|---|
| Screen Shot 2016-01-11 at 5.39.18 PM.png | 84.7 KB | banacan | |
| Screen Shot 2016-01-11 at 5.38.16 PM.png | 53.18 KB | banacan | |
| Screen Shot 2016-01-11 at 5.37.30 PM.png | 98.89 KB | banacan |
Comments
Comment #2
banacan commentedI have discovered that I can Add another item when editing a previously saved record. It appears this issue is only related to Creating a record.
Comment #3
swentel commentedHmm, the error also indicates that you're trying to upload a file, is that the case ?
Comment #4
banacan commentedNo, I'm not trying to upload a file. I was confused by that too. All I was trying to do was add another taxonomy term to a field that is defined as unlimited.
Comment #5
banacan commentedI have continued testing this issue. I created another content type with just a title, body, and two unlimited fields: one taxonomy and one integer. When entering the first record I was able to add additional items in the taxonomy list just fine. But the next record didn't let me add more than one taxonomy. So I moved on to the integer field and I was able to add as many as I liked. I went back to the taxonomy field and tried again, and this time I was able to add more terms. I have tested this multiple times and it continues to be a problem. I can enter only one taxonomy item, but if I move on to another unlimited field (integer) and later come back to the taxonomy field, then I can add more items. Interestingly, after adding the one taxonomy term I'm allowed, if I enter type in the body field and then go back to the taxonomy field, I can't add additional terms. It seems I can only add additional terms if I go to my integer field, then come back to the taxonomy field.
Here are more log entries:
Notice: Undefined index: value in Drupal\Core\Field\Plugin\Field\FieldWidget\NumberWidget->errorElement() (line 119 of /Users/brett/vhosts/ddclab/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php).
This is what the url for location says:
http://ddclab:8888/node/add/simple_test?_wrapper_format=drupal_ajax&ajax...
This is the content from the Location link:
[{"command":"add_css","data":"\u003Clink rel=\u0022stylesheet\u0022 href=\u0022http:\/\/ddclab:8888\/sites\/default\/files\/css\/css_WoUSDQq02piOhfQKmkZkre5BurnnMpHpdP6QO8aYdt8.css?o0t65i\u0022 media=\u0022all\u0022 \/\u003E\n"},{"command":"insert","method":"replaceWith","selector":null,"data":"\n \u003Cdiv role=\u0022contentinfo\u0022 aria-label=\u0022Error message\u0022 class=\u0022messages messages--error\u0022\u003E\n \u003Cdiv role=\u0022alert\u0022\u003E\n \u003Ch2 class=\u0022visually-hidden\u0022\u003EError message\u003C\/h2\u003E\n An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (32 MB) that this server supports.\n \u003C\/div\u003E\n \u003C\/div\u003E\n \n","settings":null}]
Again note that it mentions an upload file. I am not attempting to upload anything.
Here is another log entry:
Recoverable fatal error: Argument 1 passed to Drupal\Core\Form\FormState::setError() must be of the type array, null given, called in /Users/fred/vhosts/ddclab/core/lib/Drupal/Core/Field/WidgetBase.php on line 446 and defined in Drupal\Core\Form\FormState->setError() (line 1156 of /Users/fred/vhosts/ddclab/core/lib/Drupal/Core/Form/FormState.php).
The Location url:
http://ddclab:8888/node/add/simple_test?_wrapper_format=drupal_ajax&ajax...
The Location content:
[{"command":"add_css","data":"\u003Clink rel=\u0022stylesheet\u0022 href=\u0022http:\/\/ddclab:8888\/sites\/default\/files\/css\/css_WoUSDQq02piOhfQKmkZkre5BurnnMpHpdP6QO8aYdt8.css?o0t65i\u0022 media=\u0022all\u0022 \/\u003E\n"},{"command":"insert","method":"replaceWith","selector":null,"data":"\n \u003Cdiv role=\u0022contentinfo\u0022 aria-label=\u0022Error message\u0022 class=\u0022messages messages--error\u0022\u003E\n \u003Cdiv role=\u0022alert\u0022\u003E\n \u003Ch2 class=\u0022visually-hidden\u0022\u003EError message\u003C\/h2\u003E\n An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (32 MB) that this server supports.\n \u003C\/div\u003E\n \u003C\/div\u003E\n \n","settings":null}]
This is clearly a bug. What I don't know is if this should be filed under Ajax or some other section. Please review and change to the appropriate section. Also it would help if others would verify this bug by repeating the steps I have outlined.
Comment #6
banacan commentedI should mention one more finding. My input form had the taxonomy field before the integer field, and I had the problem mentioned before. I switched locations and had my integer field come first and as long as I added one (required) entry, I was then able to enter unlimited taxonomy terms without issue. This is very strange.
Comment #7
amateescu commented@banacan, can you please provide a list of all contrib modules (and their versions) that you have installed on that site?
I tried to reproduce this problem in #2619878: Recoverable fatal error: Argument 1 passed to Drupal\\Core\\Form\\ FormState::setError() must be of the type array with no luck..
Comment #8
banacan commentedI only have Devel-8.x-1.x. installed and I'm using the core Bartik theme without any customization.
Please try to reproduce this problem using my comment #5. My test content type included only 4 fields: Title, Body, Taxonomy (entity reference), and Number (integer). Again both the taxonomy and number fields are set to unlimited. My taxonomy vocabulary contains only 14 terms with only a name, no description. The test couldn't be simpler, and I did not use Devel to populate the fields.
Remember also that the problem only seems to occur when creating the record. If I edit an existing record I can add as many terms as I want.
Comment #9
swentel commentedBeen trying to reproduce this as well, and I have an error, however, I don't get the file upload error.
I actually have two errors: the formState problem, but that seems related to #2614250: Number widget validation can break AJAX actions (required number)
I also have 'Warning: implode(): Invalid arguments passed in Drupal\Core\Form\FormState->setError() (line 1157 of /home/drupal/drupal-core/core/lib/Drupal/Core/Form/FormState.php' - might be related to the one above too.
However, I can still add unlimited items with no problem. I'm trying to figure out if that ajax exception isn't fooling us in some way. Looking in FormBuilder, a BrokenPostException is thrown when post max size is too big, but that's not necessarily related to a file right ?
Comment #10
banacan commentedIs everyone testing on the same version? I am running Drupal 8.0.2. I downloaded the drupal-8.0.2.zip from the Download and Extend page. Since my setup is so bare bones: only one module installed (Devel), and default Bartik, this should be easy to reproduce.
My server environment if it helps:
iMac OSX 10.10.5, MAMP Pro v. 3.4, PHP 5.6.10, MySQL 5.5.42, Apache 2.x?
Comment #11
swentel commentedThere isn't a lot of changes between 8.0.x and 8.0.2 for now.
Running on linux, maybe it's a PHP version thing, since mine is 5.6.27 or 7.0.2
Comment #12
klasseng commentedI'd suggest disabling some of your other modules. I had a similar problem:
I disabled webprofiler and the problem went way.
Comment #13
claudiu.cristeaSo it's devel/webprofiler.
Comment #14
banacan commentedHey, it's worth a try. I'll update you after I have disabled devel.
Comment #15
colinstillwell commentedMy test case seems new to everything else that has been said on this issue. I have a custom entity with some fields on it, one of them being an inline entity form and another being number (integer).
I have received the following messages in watchdog that look like they relate to this issue as well:
"Notice: Undefined index: value in Drupal\Core\Field\Plugin\Field\FieldWidget\NumberWidget->errorElement() (line 119 of /srv/www/d8/web/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php)."
"Recoverable fatal error: Argument 1 passed to Drupal\Core\Form\FormState::setError() must be of the type array, null given, called in /srv/www/d8/web/core/lib/Drupal/Core/Field/WidgetBase.php on line 446 and defined in Drupal\Core\Form\FormState->setError() (line 1156 of /srv/www/d8/web/core/lib/Drupal/Core/Form/FormState.php)."
I am not sure if this only relates to the problem I am having or not, but if I provide a value in my number (integer) field it then allows me to use my inline entity reference field without any errors or warnings.
My contrib modules are as follows:
- adminimal_theme
- commerce
- features
- inline_entity_form
Comment #16
colinstillwell commentedFYI, the patch in https://www.drupal.org/node/2614250 seems to resolve my issue. I just wanted to throw another test case into the mix!
Comment #17
banacan commentedI have tried disabling devel but my problem persists. With devel disabled I am still only able to input one taxonomy term in the unlimited field. To add more I must move to my unlimited numeric field, add at least one item, then I can go back to my taxo field and add as many terms as I like. This is very strange behavior.
Comment #18
charlotte.b commentedcolinstillwell88 thank you, this patch https://www.drupal.org/node/2614250 worked for me. Looks like it's a core bug if you have a required integer field with entity reference fields too.
Comment #19
cilefen commentedCan we mark this a duplicate of #2614250: Number widget validation can break AJAX actions then?
Comment #20
banacan commentedI don't think this is a duplicate because the broken functionality of unlimited taxonomy terms is what is at issue here. The only connection with Numbers is that in order to add additional taxonomy terms requires adding another unlimited item first (in my case a number).
Comment #21
swentel commented@banacan actually, I think it is. It has todo with the fact that in case number is required, errors start popping up. If the number is not required, then there doesn't seem to be a problem. Is your numeric field required ? If so, then the other patch should solve the issue.
Comment #22
banacan commentedI see what you mean. Yes, my number is a required field. I am very new to Drupal so I don't know how to apply a patch. I downloaded D8 from the download page. How do I install the patch?
Comment #23
gnuget#22 check this out.
https://www.drupal.org/patch/apply
Comment #24
swentel commented@banacan In case that doesn't work out immediately, find following file:
NumberWidget.php in the "core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget" folder.
Go to the end of the file and change
to
Comment #25
banacan commented@gnuget
Thanks for the link.
@swentel
I used your method for the fix and it worked great. That seems to have taken care of my problem. Will this be corrected in the next release, or will I have to make the change again?
Comment #26
cilefen commented@banacan A few more things have to happen for that. First there will be a patch to change the core code, then a message that it has been committed to a branch. If committed, a bug fix usually appears in the next release.
Comment #27
banacan commented@cilefen Thanks for the info. I guess I'll just keep an eye on this and continue to update NumberWidget.php as needed.
Thanks to everyone for helping on this.
Comment #28
colinstillwell commented@banacan I was once in the same boat as you, manually applying patches when needed. I now use builds where it applies patches for me. Anyway... If you find it hard to remember which projects have been modified I would strongly suggest looking at https://www.drupal.org/project/hacked its a great module for telling you which projects have been modified :-)
Comment #29
banacan commented@ colinstillwell88 Thanks for that excellent suggestion.
Comment #30
gnugetThis time can we mark this as duplicate of #2614250: Number widget validation can break AJAX actions? :-D
Comment #31
banacan commentedIt seems you were right before. I would say yes to marking as a dup.
Comment #32
swentel commentedyes.
Comment #33
amateescu commentedThis will be fixed by #2901943: Content entity form validation does not respect the #limit_validation_errors property from field widgets.