platform icon indicating copy to clipboard operation
platform copied to clipboard

Autocompleting Public Properties - error on boolean false value

Open m3rlo87 opened this issue 1 year ago • 1 comments

Describe the bug If an item with the Boolean value false is returned in the return of the query function of a screen, the autocompletion of public properties fails.

To Reproduce

  1. Create a new Screen class extending App\Orchid\Screens\BaseScreen
use Orchid\Screen\Screen as Screen;
class DemoScreen extends BaseScreen
  1. Declare 3 public properties in the class
    public $var1 = null;
    public $var2 = null;
    public $var3 = null; 
  1. Define the query function by returning an array with 3 keys corresponding to the names of the three properties, as described in the documentation. The first element of the array must be a Boolean value false. The elements after the first can be any value.
public function query(Request $request): array
    {
        return [
            'var1' => false,
            'var2' => "example1",
            'var3' => "example2"
        ];

    } 
  1. Define the layout function by printing the value of $this->var2
public function layout(): array
  {
      dd($this->var2);
  } 
  1. Check the printed output, it will be "null" or the default value of the var2 variable.

Expected behavior string "example1" is expected.

Screenshots image image

Server (please complete the following information):

  • Platfrom Version: 14.17.0
  • Laravel Version: 10.38.0
  • PHP Version: 8.1

Additional context If the array returning from query function contains a boolean false value, the Autocompleting Public Properties does not work and values are not set to public properties.

m3rlo87 avatar Dec 30 '23 01:12 m3rlo87

In Orchid\Screen\Screen class, in function fillPublicProperty each function is used to iterate properties.

Laravel Each function stop iterating if the callback returns false.

m3rlo87 avatar Dec 30 '23 01:12 m3rlo87

Thank you for reaching out, and I apologize for the delay in response. At the moment, I don't seem to notice the issue you mentioned. It's possible that I have already addressed it earlier but forgot to mention it here.

tabuna avatar May 30 '24 00:05 tabuna