Issue with Displaying and Saving Related Fields in CRUD Edit Screen #1142
-
Hello, I’m still having an issue with displaying and saving related fields in my CRUD interface. I think my previous explanation may not have been clear, so I’ll try again. I have two models:
namespace App\Models; use Backpack\CRUD\app\Models\Traits\CrudTrait; class User extends Authenticatable implements MustVerifyEmail
2.AccountVerifciation model: `<?php namespace App\Models; use Backpack\CRUD\app\Models\Traits\CrudTrait; class AccountVerification extends Model
` I want to display the “risk” field from the “User” model in the AccountVerification CRUD edit view. Additionally, I need any changes made to this “risk” field within the AccountVerification edit view to be correctly saved back to the database. Currently, I have implemented it as follows in my CRUD setup, but the changes to the “risk” field are not being saved. `<?php namespace App\Http\Controllers\Admin; use App\Http\Requests\AccountVerificationRequest; /**
Thank you very much!!!! Oscar |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello @infiniteroles First you need to add "risk" to the fillable on "AccountVerification" model. Then to handle it i recommend use Accessor and Mutator in "AccountVerification" model, like this:
Finally, with this set, you can simplify your controller field:
This should work, let me know if you need any further help. Cheers. |
Beta Was this translation helpful? Give feedback.
-
Im glad this work for you. I will close the issue now, but please feel free to re-open or create a new one. Cheers. |
Beta Was this translation helpful? Give feedback.
Hello @infiniteroles
First you need to add "risk" to the fillable on "AccountVerification" model.
Then to handle it i recommend use Accessor and Mutator in "AccountVerification" model, like this:
Finally, with this set, you can simplify your controller field: