Hi @daft There is a possible bug in taglist form widget’s preview mode since v3.6.26 . I see there was significant changes. My filed definisition:
services:
label: Services
type: taglist
mode: array
useKey: true
customTags: false
placeholder: Válassz szolgáltatásokat
optionsMethod: BrightStaff\BrightGage\Helpers\FieldHelper::servicesOptions
span: auto
servicesOptions method returns:
return [
1 => 'kalibrálás',
2 => 'kereskedelem',
3 => 'szerviz'
];
Services stored as json in the db and added to the jsonable Model property. In preview mode I get this error:
str_starts_with(): Argument #1 ($haystack) must be of type string, October\Rain\Element\OptionDefinition given
~/vendor/october/rain/src/Translation/Translator.php line 98
I don’t know exactly what is going on but if I modify _taglist.php like this:
from:
$previewOptions = $this->getPreviewOptions($selectedValues, $fieldOptions);
to:
`$previewOptions = $this->getPreviewOptions($selectedValues, $flatOptions);`
$fieldOptions
are declared in the TagList Class and passed to the view and than redeclered here.
Any suggestion? Thanks in advance.
daft
November 11, 2024, 10:03pm
#2
Hey @danielbidala
I made a test for this here: Testing taglist in preview mode · octobercms/test-plugin@4e0dd90 · GitHub
Unfortunately, I can’t reproduce it…
Navigate to Playground → Trees
Edit any Channel from the list
Add a tag to the Services field
Click Save
Replace “update” with “preview” in the browser URL
The Services field renders without any errors
Perhaps check that you are running the latest code base, including the october/rain
library.
Hi @daft and many thanks for your investigation. I get the same error message with test plugin. My October version is 3.7.4 currently but I tried with dev-develop too. I spent a day with this issue without any luck. Below is my stack trace (sorry, it’s a bit long).
I have absolutly no idea what is happening but as I mentioned in my original post, with the change of that one variable in _taglist.php everything is working fine.
We're sorry, but an unhandled error occurred. Please see the details below.
str_starts_with(): Argument #1 ($haystack) must be of type string, October\Rain\Element\OptionDefinition given
~/vendor/october/rain/src/Translation/Translator.php line 98
* ### Type
Undefined
* ### Exception
TypeError
92
93
94
95
96
97
98
99
100
101
102
103
104 `/**`
` ` `* getValidationSpecific checks the system namespace by default for "validation" keys`
` ` `*/`
`protected function getValidationSpecific($key, $replace, $locale)`
`{`
` ` `if (`
` ` `str_starts_with($key, 'validation.') &&`
` ` `!str_starts_with($key, 'validation.custom.') &&`
` ` `!str_starts_with($key, 'validation.attributes.')`
` ` `) {`
` ` `$nativeKey = 'system::'.$key;`
` ` `$line = $this->get($nativeKey, $replace, $locale);`
` ` `if ($line !== $nativeKey) {`
### Stack Trace
|#|Called Code|Document|Line|
| --- | --- | --- | --- |
|76|str_starts_with(…)|~/vendor/october/rain/src/Translation/Translator.php|98|
|75|October\Rain\Translation\Translator->getValidationSpecific(…)|~/vendor/october/rain/src/Translation/Translator.php|25|
|74|October\Rain\Translation\Translator->get(…)|~/vendor/october/rain/src/Translation/Translator.php|122|
|73|October\Rain\Translation\Translator->trans(…)|~/vendor/october/rain/src/Support/helpers.php|275|
|72|trans(…)|~/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php|973|
|71|__(…)|~/modules/backend/formwidgets/taglist/partials/_taglist.php|38|
|70|include(…)|~/modules/system/traits/ViewMaker.php|272|
|69|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|68|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/formwidgets/TagList.php|130|
|67|Backend\FormWidgets\TagList->render()|~/modules/backend/widgets/form/partials/_field_widget.php|5|
|66|include(…)|~/modules/system/traits/ViewMaker.php|272|
|65|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|64|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/widgets/Form.php|341|
|63|Backend\Widgets\Form->renderFieldElement(…)|~/modules/backend/widgets/form/partials/_field.php|25|
|62|include(…)|~/modules/system/traits/ViewMaker.php|272|
|61|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|60|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/widgets/form/partials/_field-container.php|9|
|59|include(…)|~/modules/system/traits/ViewMaker.php|272|
|58|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|57|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/widgets/form/partials/_form_fields.php|11|
|56|include(…)|~/modules/system/traits/ViewMaker.php|272|
|55|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|54|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/widgets/form/partials/_form_tabs.php|63|
|53|include(…)|~/modules/system/traits/ViewMaker.php|272|
|52|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|51|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/widgets/form/partials/_section.php|27|
|50|include(…)|~/modules/system/traits/ViewMaker.php|272|
|49|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|48|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/widgets/form/partials/_form.php|6|
|47|include(…)|~/modules/system/traits/ViewMaker.php|272|
|46|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|45|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/widgets/form/partials/_form-container.php|7|
|44|include(…)|~/modules/system/traits/ViewMaker.php|272|
|43|Backend\Classes\WidgetBase->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|103|
|42|Backend\Classes\WidgetBase->makePartial(…)|~/modules/backend/widgets/Form.php|246|
|41|Backend\Widgets\Form->render(…)|~/modules/backend/behaviors/formcontroller/HasRenderers.php|52|
|40|Backend\Behaviors\FormController->formRenderPreview()|||
|39|call_user_func_array(…)|~/vendor/october/rain/src/Extension/ExtendableTrait.php|504|
|38|October\Rain\Extension\Extendable->extendableCall(…)|~/vendor/october/rain/src/Extension/Extendable.php|55|
|37|October\Rain\Extension\Extendable->__call(…)|~/plugins/october/test/controllers/channels/preview.htm|11|
|36|include(…)|~/modules/system/traits/ViewMaker.php|272|
|35|Backend\Classes\Controller->makeFileContents(…)|~/modules/system/traits/ViewMaker.php|117|
|34|Backend\Classes\Controller->makeView(…)|~/modules/backend/classes/Controller.php|406|
|33|Backend\Classes\Controller->execPageAction(…)|~/modules/backend/classes/Controller.php|274|
|32|Backend\Classes\Controller->run(…)|~/modules/backend/classes/BackendController.php|137|
|31|Backend\Classes\BackendController->run(…)|~/vendor/laravel/framework/src/Illuminate/Routing/Controller.php|54|
|30|Illuminate\Routing\Controller->callAction(…)|~/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php|43|
|29|Illuminate\Routing\ControllerDispatcher->dispatch(…)|~/vendor/laravel/framework/src/Illuminate/Routing/Route.php|259|
|28|Illuminate\Routing\Route->runController()|~/vendor/laravel/framework/src/Illuminate/Routing/Route.php|205|
|27|Illuminate\Routing\Route->run()|~/vendor/laravel/framework/src/Illuminate/Routing/Router.php|798|
|26|Illuminate\Routing\Router->Illuminate\Routing\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|141|
|25|Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php|50|
|24|Illuminate\Routing\Middleware\SubstituteBindings->handle(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|180|
|23|Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php|49|
|22|Illuminate\View\Middleware\ShareErrorsFromSession->handle(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|180|
|21|Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php|121|
|20|Illuminate\Session\Middleware\StartSession->handleStatefulRequest(…)|~/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php|64|
|19|Illuminate\Session\Middleware\StartSession->handle(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|180|
|18|Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php|37|
|17|Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|180|
|16|Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php|67|
|15|Illuminate\Cookie\Middleware\EncryptCookies->handle(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|180|
|14|Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|116|
|13|Illuminate\Pipeline\Pipeline->then(…)|~/vendor/laravel/framework/src/Illuminate/Routing/Router.php|797|
|12|Illuminate\Routing\Router->runRouteWithinStack(…)|~/vendor/laravel/framework/src/Illuminate/Routing/Router.php|776|
|11|Illuminate\Routing\Router->runRoute(…)|~/vendor/laravel/framework/src/Illuminate/Routing/Router.php|740|
|10|Illuminate\Routing\Router->dispatchToRoute(…)|~/vendor/october/rain/src/Router/CoreRouter.php|32|
|9|October\Rain\Router\CoreRouter->dispatch(…)|~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php|190|
|8|Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|141|
|7|Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php|86|
|6|Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(…)|~/vendor/october/rain/src/Foundation/Http/Middleware/CheckForMaintenanceMode.php|23|
|5|October\Rain\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|180|
|4|Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…)|~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php|116|
|3|Illuminate\Pipeline\Pipeline->then(…)|~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php|165|
|2|Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(…)|~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php|134|
|1|Illuminate\Foundation\Http\Kernel->handle(…)|~/index.php|42|
I tried on production server, just in case it’s a different codebase or an apache, php or sql issue. I get the same error.
Eoler
November 20, 2024, 6:26am
#5