- Issue created by @DiDebru
- last update
about 1 year ago 2 pass - Status changed to Needs review
12 months ago 8:36am 8 January 2024 - 🇮🇳India SandeepSingh199
Hi @DiDebru, I got the same issue while trying to add New Rows in table. After your patch, its working fine.
Marking this ticket to Needs Review.
- 🇧🇪Belgium tvb
Similar problem here (version 8.x-2.4):
The website encountered an unexpected error. Please try again later. TypeError: Cannot access offset of type string on string in Drupal\tablefield\Plugin\Field\FieldType\TablefieldItem->setValue() (line 187 of modules/contrib/tablefield/src/Plugin/Field/FieldType/TablefieldItem.php).
It is resolved after installing the patch.
- 🇧🇪Belgium tvb
Ignore my previous comment.
Apparently the configuration settings at /admin/config/content/tablefield had disappeared.
The TypeError message is gone after setting a CSV separator and defaults for number of rows and columns.
No patch required.
- First commit to issue fork.
- 🇺🇸United States erutan
I wasn't able to recreate the issue, but it applies cleanly and fixes typos with rebuild being repeated that would stop it from being applied to earlier levels in the array.
This should go into 3.0.x
-
liam morland →
committed 77b6919d on 8.x-2.x
Issue #3399529: Fix coding standards issue from parent commit
-
liam morland →
committed 77b6919d on 8.x-2.x
-
liam morland →
committed 7227300b on 3.0.x authored by
didebru →
Issue #3399529: Error: Cannot unset offset in a non-array variable in...
-
liam morland →
committed 7227300b on 3.0.x authored by
didebru →
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
This change is triggering a phpstan error: "Cannot unset offset 'tablefield' on array." in
src/Plugin/Field/FieldType/TablefieldItem.php
.$values['tablefield']
is already unset in the previous line, so unsetting$values['tablefield']['rebuild']
does nothing. This suggests to me that something is wrong with the change. At least, this line should be removed:unset($values['tablefield']['rebuild']);
- 🇺🇸United States erutan
Sorry about missing that - I have phpstan running in my dev environment again though that should have been obvious.
It seems the typo from ten years ago was putting [rebuild] on a new line (as well as duplicating it), rebuild seems to just be there to help restructure the data and then isn't needed after.
elseif (!empty($values['tablefield'])) { $values['rebuild'] = $values['tablefield']['rebuild']; $values['value'] = $values['tablefield']['table']; unset($values['tablefield']['rebuild']); }
The elseif statement below it only unsets rebuild.
elseif (!empty($values['value']['tablefield'])) { $values['rebuild'] = $values['value']['tablefield']['rebuild']; $values['value'] = $values['value']['tablefield']['table']; unset($values['value']['tablefield']['rebuild']); }
Does that seem right?
- 🇬🇧United Kingdom thetwentyseven
Still with this latest version which has already merge this patch I do have a similar problem:
An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /node/add/product_page?ajax_form=1&_wrapper_format=drupal_ajax StatusText: error ResponseText: The website encountered an unexpected error. Try again later.TypeError: Cannot access offset of type string on string in Drupal\tablefield\Plugin\Field\FieldType\TablefieldItem->setValue() (line 171 of modules/contrib/tablefield/src/Plugin/Field/FieldType/TablefieldItem.php). Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue(Array, 1) (Line: 107)
- 🇺🇸United States erutan
@thetwentyseven not seeing that on my side. Do you have steps to reproduce?
- 🇬🇧United Kingdom thetwentyseven
Never mind @erutan, I deleted everything and reinstalled the module, and now is working as expected. Thank you