KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Fields in admin panels: Manual assign #3449

Open Amr Abdelaal opened this topic on on Jun 19 - 6 comments

Amr Abdelaal commented on Jun 19

Setting Type [Widget] type_input Message: No fields is found! Line: 37 File: /workspaces/vendor/koolreport/dashboard/inputs/Select.php

 Text::create("type")
                ->inputWidget(
                    Select::create()
                        ->dataSource(function () {
                            return [
                                "string" => "string",
                                "integer" => "integer",
                                "boolean" => "boolean",
                                "json" => "json",
                                "date" => "date"
                            ];
                        })
                )
                ->label("Setting Type")

![](https://cdn.koolreport.com/assets/images/editor/c5/image6854328cf31ec.png)
Sebastian Morales commented on Jun 20

Pls make sure the data column with name "type" exists exactly and case sensitively, i.e. not as "Type" or "TYPE".

Amr Abdelaal commented 7 days ago

the table column name is type exactly as in the code. I even copy and past the name fomr the Datbase schema.

Sebastian Morales commented 4 days ago

Pls try to add set fields property for your Select input like this:

     Text::create("type")
                ->inputWidget(
                    Select::create()
                        ->dataSource(function () {
                            return [
                                "string" => "string",
                                "integer" => "integer",
                                "boolean" => "boolean",
                                "json" => "json",
                                "date" => "date"
                            ];
                        })
                    ->fields(function(){
                        return [
                            Text::create("type"),
                        ];
                    })
                ) 
    ...
Amr Abdelaal commented 16 hours ago

No errors now, but the select input is empty and does not show the dataSource options.

Sebastian Morales commented 3 hours ago

Pls try the following returned data in your Select's dataSource:

     Text::create("type")
                ->inputWidget(
                    Select::create()
                        ->dataSource(function () {
                            // return an array of rows, every of which has a key "type"                    
                            return [
                                ["type" => "string"],
                                ["type" => "integer"],
                                ["type" => "boolean"],
                                ["type" => "json"],
                                ["type" => "date"]
                            ];
                        })
                    ->fields(function(){
                        return [
                            Text::create("type"),
                        ];
                    })
                )  
Sebastian Morales commented 3 hours ago

Here is another solution if you want to separate value/text:

Text::create("type")
->inputWidget(
    \koolreport\dashboard\inputs\Select::create()
    ->dataSource(function () {
        return [
            ["value"=>"string",  "text"=>"String"],
            ["value"=>"integer", "text"=>"Integer"],
            ["value"=>"boolean", "text"=>"Boolean"],
            ["value"=>"json",    "text"=>"JSON"],
            ["value"=>"date",    "text"=>"Date"],
        ];
    })
    ->fields([
        \koolreport\dashboard\fields\Text::create("value"),
        \koolreport\dashboard\fields\Text::create("text"),
    ])
); 

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Dashboard