#Saved data not showing in multiselect field

9 messages · Page 1 of 1 (latest)

slate knot
#

What I am trying to do:
Displaying the data that is picked from the multiselect.

What I did:
Made a new column in the database:

$table->json('value_types')->nullable();

Set cast to array & added it as fillable in the model.

Then in my resource added the following:

Select::make('value_types')
    ->label('Toon meter waarde')
    ->options([
      'temperature' => 'Temperatuur',
      'co2' => 'CO2',
      'movement' => 'Beweging',
      'pressure' => 'Druk',
      'illuminance' => 'Verlichting',
      'io_status' => 'IO Status',
      'humidity' => 'Vochtigheid',
     ])
     ->searchable()
     ->multiple()
     >columnSpan(2),

My issue/the error:
Values are saved correctly in the database, but when i reopen the form the multiselect field is empty. So it's not showing the values i just saved. When i then save the fields again it saves an empty array.

rare iron
#

When you save and dump the data, what does it actually return? Like dd($yourModel->value_types)?

umbral frigate
slate knot
#

Thanks for the replies! Will try it monday when i'm back at the office 🙂

slate knot
#

It shows when i just saved it, but when i refresh the page or go back to a different one it doesn't show it anymore

unborn rapids
#

Did the database update?

Do you have it as fillable on your model?

slate knot
#

Yes database did update

unborn rapids