Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: When saving range, "foreach() argument must be of type array|object, string given" exception thrown #37

Open
brianakidd opened this issue Aug 12, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@brianakidd
Copy link

What happened?

When saving, this exception was through in the hydrate Livewire function. The payload:

{
    "_token": "Tolh9pC4Wnw9mQRQqYwCIUFblXkEADlWAT54m8FA",
    "components": [
        {
            "snapshot": "{\"data\":{\"data\":[{\"id\":1,\"start\":\"2023-08-17\",\"end\":\"2023-08-18\",\"leave_time\":null,\"color\":null,\"notes\":null,\"team_id\":1,\"created_at\":\"2023-08-11T12:36:57.000000Z\",\"updated_at\":\"2023-08-11T19:57:53.000000Z\",\"dates\":[[\"2023-08-17\",\"2023-08-18\"],{\"s\":\"arr\"}]},{\"s\":\"arr\"}],\"previousUrl\":\"http:\\/\\/arrow.test\\/app\\/armstrong\\/assignments\",\"mountedActions\":[[],{\"s\":\"arr\"}],\"mountedActionsArguments\":[[],{\"s\":\"arr\"}],\"mountedActionsData\":[[],{\"s\":\"arr\"}],\"componentFileAttachments\":[[],{\"s\":\"arr\"}],\"mountedFormComponentActions\":[[],{\"s\":\"arr\"}],\"mountedFormComponentActionsArguments\":[[],{\"s\":\"arr\"}],\"mountedFormComponentActionsData\":[[],{\"s\":\"arr\"}],\"mountedFormComponentActionsComponents\":[[],{\"s\":\"arr\"}],\"activeRelationManager\":null,\"record\":[null,{\"class\":\"App\\\\Models\\\\Assignment\",\"key\":1,\"s\":\"mdl\"}]},\"memo\":{\"id\":\"B9flOQkhwoBlhEDgy1z3\",\"name\":\"app.filament.resources.assignment-resource.pages.edit-assignment\",\"path\":\"app\\/armstrong\\/assignments\\/1\\/edit\",\"method\":\"GET\",\"children\":[],\"lazyLoaded\":true,\"errors\":[],\"locale\":\"en\"},\"checksum\":\"81dc22fc8b5cc1c5aad920a817bbc88782f569c00a1cacc3874c62906623ff30\"}",
            "updates": {
                "data.dates": "2023-08-22"
            },
            "calls": [
                {
                    "path": "",
                    "method": "save",
                    "params": []
                }
            ]
        }
    ]
}

The dates property seems to be wrapped in an inner array:

"dates\":[[\"2023-08-17\",\"2023-08-18\"],{\"s\":\"arr\"}]},{\"s\":\"arr\"}]

How to reproduce the bug

Add component to form:

public static function form(Form $form): Form
{
  return $form
    ->schema([
      Flatpickr::make('dates')
        ->range()
        ->altInput()
        ->altFormat('D n/j/y')

Edit record by setting new value and saving.

Package Version

3.0.1

PHP Version

8.2

Laravel Version

10

Which operating systems does with happen with?

macOS, Linux

Notes

No response

@brianakidd brianakidd added the bug Something isn't working label Aug 12, 2023
@Reached
Copy link

Reached commented Aug 29, 2023

EDIT I just realised that brianakidd already added the necessary info, sorry about that :)

To add a bit more context, I experienced that this only occurs for me upon saving an existing record (when editing). So creating the record seems to go fine, but when updating it seems to break.

I am using a json column if that matters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants