Coder Social home page Coder Social logo

filament-select-relationship-issue's Introduction

In this repo, I'm using the Shield plugin for the user roles/permissions in my Filament panel. The user resource has the following select field with relationship-sourced options for the role assignement. The issue isn't specific to the Shield plugin, that's just where I initially noticed the issue and the code I have on-hand.

Forms\Components\Select::make('roles')
    ->label('Role')
    ->preload()
    ->relationship(titleAttribute: 'name')
    ->required()
    ->searchable(),

Since Filament 3.2.79, setting the role causes the following error when saving:

array_diff(): Argument #2 must be of type array, string given

Downgrading to 3.2.78 fixes the issue. The issue isn't present when using options() with the select. The error appears to originate on Select.php#L994-L1000. It seems to be expecting an array but the select is returning a single value.

Steps to reproduce the issue

1. Clone the repo git clone <url>

2. CD into the project cd filament-select-relationship-issue

3. Composer composer install

4. Create the .env config cp .env.example .env

5. Generate the application key php artisan key:generate

6. Serve the project php artisan serve

7. Login Vist http://127.0.0.1:8000 and log in - the user/pass is preconfigured.

8. Create a user Navigate to the user resource and create a new user. The user will be created but the selected role will not be assigned. The application will error with the following:

array_diff(): Argument #2 must be of type array, string given

9. Edit a user The same will happen if you edit a user and assign a new role.

filament-select-relationship-issue's People

Contributors

cg-sthomas avatar

Watchers

Steven Thomas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.