I expected to get a null value as if the repeatable field had never been compiled.
The field return a string (2) "[]"
Asking if this is the expected behavior
When I run php artisan backpack:version the output is:
PHP 7.3.15 (cli) (built: Feb 18 2020 12:45:47) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.15, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.9.4, Copyright (c) 2002-2020, by Derick Rethans
v7.11.0@f4563bd2e0875c59a1f7967abdbe5cef7f240117
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps _a lot_ in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication channels:
backpack-for-laravel tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
--
Justin Case
The Backpack Robot
It's the expected behaviour.
This is actually a question of "what is the default value of the repeatable input". Please note that the input value of repeatable will always be string as was intended to be used with json_decode.
Now, if you create a repeatable, leave it untouched and submit, it will give you a json string, and decode it it'll show something like:
array:1 [
0 => array:3 [
"name" => "",
"email" => "",
"mobile" => "",
]
]
If you click on the cross and delete the default element, you know that under the hood the array is removing one of its associating child element. In our case, it removes array[0], and the remaining is an empty array.
In such situation, __repeatable field return '[]' string after deleting all entries__ is an expected behaviour. AFAIK it is intact with other backpack input element concerning json.
If you think such behaviour gives you some troubles, you can illustrate an example situation, perhaps it worths further discussion.
It makes totally sense.
I had a default null value in the repeatable column entries because i added that column in an existent table.
I am going to close the issue.
Thanks a lot.
Wow - thanks a lot for the detailed explanation @justinmoh - I couldn't explain it so clearly even if I tried. Good job!
Most helpful comment
It's the expected behaviour.
This is actually a question of "what is the default value of the
repeatableinput". Please note that the input value ofrepeatablewill always be string as was intended to be used withjson_decode.Now, if you create a repeatable, leave it untouched and submit, it will give you a json string, and decode it it'll show something like:
If you click on the cross and delete the default element, you know that under the hood the array is removing one of its associating child element. In our case, it removes
array[0], and the remaining is an empty array.In such situation, __repeatable field return '[]' string after deleting all entries__ is an expected behaviour. AFAIK it is intact with other backpack input element concerning json.
If you think such behaviour gives you some troubles, you can illustrate an example situation, perhaps it worths further discussion.