0

I try using multiselect when creating record but I get error Array to String. But when I update record everything is ok.

            Panel::make('Material', [
            MultiSelect::make('Select materials', 'material_id')
                ->options(Material::orderBy('name', 'ASC')->get()->pluck('name', 'id'))
                ->hideFromIndex(),
        ]),

I need hide this filed when creating record to use him on update.

Thanks.

1 Answer 1

0

What database type is material_id? Make sure it's a database field that allows to save array's.

One other thing that could cause this if you didn't cast the field in your model to array

<?php

namespace App\Models;

class Model
{
    protected $casts = [
        'material_id' => 'array',
    ];
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot :) A forget about cast in model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.