-
Notifications
You must be signed in to change notification settings - Fork 920
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
Attribute Casting causes error #66
Comments
Hi @dmrc1143 , You're right, Backpack should support attribute casting. And I think the change is as easy as replacing The change isn't very difficult, but needs to be done in a lot of blade files (all field types, all column types, all button types). I'm on it, but it will take a few days to do it all and properly test it. If you're in a rush, you can do it yourself for the few field types you need, until I get to change them all. Cheers! |
Thank you for your interest, |
Great. Will do! |
Hi @dmrc1143 , It's done in
As far as I can figure it out, we've now covered most attribute castings:
But I don't think we should support casting to objects or collections. They can be so different that it's super-difficult to create fields or columns for them... I think for collections and objects, the developers should build their own column or field types. |
Thank you for fixing, |
Hi,
Everything works fine, just one part. When I insert new article with images, but when I want |
If you error only shows up on the table view, it means the problem is with the column type you're using to display that array. What column type are you? If you use a "text" column, naturally it will throw an error, because you're trying to display an array as text. You should use the array column type or write your own if none fit your needs. Cheers! |
Hi @tabacitu, Thank you for fast response. I am using $this->crud->addField([ // Select2
'label' => "Category",
'type' => 'select2',
'name' => 'category_id', // the db column for the foreign key
'entity' => 'article_category', // the method that defines the relationship in your Model
'attribute' => 'name', // foreign key attribute that is shown to user
'model' => "App\Models\Article_category" // foreign key model
]); in my controller, and how I can add array column type? In migration or model? |
If you were editing Cars, for example, you'd have a CarCrudController. Right? Well, in your CarCrudController, in the So that's where you need to poke around - CarCrudController. You can find the link to the array column type in my previous comment. Take a look at all available functions to understand what you can do inside __construct or setup(). Cheers! |
Sorry, in last post I added wrong code. In my controller I have this code in constructor |
I founded solution, I realized that i addField addColumn are different methods. Thank you very much! |
Hello! I have one problem with multiple uploadings, error say strip_tags() expects parameter 1 to be string, array given (View: C:\xampp\htdocs\vendor\backpack\crud\src\resources\views\columns\text.blade.php) Pliz help me< thank u |
Hi, I use eloquent attribute casting and I have
protected $casts = [ 'mentions' => 'array', ];
in my model. It causes
error when I hit the admin/somecrudpage .If I remove $casts, there is no problem. So, I think Backpack/Crud needs to support eloquent attribute casting.
I will be happy if you help me to makeshift for this issue because I have a project to done. Or I prefer if you commit for solving this problem :)
The text was updated successfully, but these errors were encountered: