Support the ongoing development of Laravel.io →
Input Eloquent Forms
Last updated 3 months ago.
0

I guess your Code::getList('abc') is returning null on your L5.1 copy, and as a result you are concatenating null with array.

Edit: Try make getList() return an empty array instead?

Last updated 7 years ago.
0

awsp, thanks for the suggestion, but my getList() is not returning null. It is returning all expected data.
As you can see from my example code above, the second snippet works fine (without the appended content)

In other words, if I use only the Code::getList('abc'), I do not get the error and I see all the expected select options. The error happens only when the ['' => '- select a value -'] + is present. Again, this line works perfectly fine on Laravel 5.0. It only fails in 5.1. Same exact code.

0

Update: I found this on LaravelCollective/html at Github: https://github.com/LaravelCollective/html/issues/60

Seems like it may be broken right now. Any suggestions?

0

Try ['' => 'something'] + Code::getList('abc').toArray().

The problem is that you can't "sum up" arrays with Collections (anymore?). I've solved it in the past by simply appending .toArray() to the Collection in the Form builder element.

Last updated 7 years ago.
0

JorisDebonnet, Thank you for the suggestion. I tried appending .toArray() within the form builder element as you mentioned, but this did not resolve the issue. I still get the same error.

0

In any case, that's where the problem is: the error says that you can't use the operand + for the expressions you're using it for. Perhaps try debugging it preparing the array on beforehand (before sending it to the template) and trying to var_dump the result of that .toArray() call. Perhaps it gives null or something, if the query failed.

Last updated 7 years ago.
0

You are getting that php fetal error because you are trying to add 2 different types. It could be null or other types such as integer , class,etc

Maybe you should double check the data type your getCode() is returning.

As you have said it's working on previous version that was why I suspect it was some potential bug you were not aware during L5

Best of luck!

0

After going crazy trying to figure this out, I found the solution. It was a dumb mistake on my part and a very simple fix. I was using ['' => 'something'] + Code::getList('abc').toArray() as suggested by JorisDebonnet when I should have been using ['' => 'something'] + Code::getList('abc')->toArray()

Note the syntax is not dot-notation, but rather a call to an object method. No hard feelings JorisDebonnet? You had the right idea. It was my fault for not thinking straight. I simply overlooked this. I guess I have been using too much JavaScript lately and didn't think twice about what I was writing. So, yes, you need to convert the object to an array.. just make sure you use the proper syntax to do so!!

Thanks to all for your suggestions!

Last updated 7 years ago.
0

@djtechonline i think if Code::getList('abc')->toArray() was having a data and its not empty. your code will work normally.

0

Sign in to participate in this thread!

LoadForge

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.