Inputs Methods


01. input Method

You can use this method to start creating a new input.

if you make input name as the next example "name.en" then you can access it in store and update requests this way $request->name->en

$datatable->input("name.en")->type("text");
// render input if condition true
$datatable->input(function() {
    if (true) {
        return "status";
    }
});

02. editForm Method

You can use this method to add the input to the edit form only, by default it will be added in all forms.

$datatable->input("name.en")->editForm();

03. createForm Method

You can use this method to add the input to the create form only, by default it will be added in all forms.

$datatable->input("name.en")->createForm();

04. page Method

You can use this method to make the input added in the custom form page number.

$datatable->input("name.en")->page(1);

05. parentClass Method

You can use this method to add class to the parent element.

$datatable->input("name.en")->parentClass("col-md-3");

06. labelClass Method

You can use this method to add class to the label element.

$datatable->input("name.en")->labelClass("mb-1");

07. type Method

use this method to set the input type.

$datatable->input("name.en")->type("text");

08. select Method

you can use this method to make a select tag.

this method accepts two arguments the first one for options label column name by default its name and the second one is for options value column name by default its id.

$datatable->input("select")
    ->select("name.en")
    ->options([
        ["id" => 1, "name" => ["en" => "datatable-1"]],
        ["id" => 2, "name" => ["en" => "datatable-2"]],
    ]);

09. multiSelect Method

you can use this method to make a multi-select input.

this method accepts three arguments the first one for options label column name by default its name , the second one is for options value column name by default its id and the last one is for multiple selection by default its true.

in the edit form when multiSelect is multiple and you remove any selected options you will get the values of those options in the update request in request key starts with remove_ then the input name.

$datatable->input("multi")
    ->multiSelect("name.en")
    ->options([
        ["id" => 1, "name" => ["en" => "datatable-1"]],
        ["id" => 2, "name" => ["en" => "datatable-2"]],
    ]);

10. Get select options on search

if you want to get multiSelect options on search you can use optionsRoute() method.

and you can use $request->search to access the search value from this route.

$datatable->input("multi")
    ->multiSelect("name.en")
    ->optionsRoute(route("get_select_options"));

11. onChange Method

you can use this method to update select options on other select change.

this method accepts two arguments the first one for the select name to update and the second one is for the route to get options from it.

you can use $request->value to access the selected option value in the onChange route.

$datatable->input("select1")
    ->select("name.en", "val")
    ->options([
        ["val" => 1, "name" => ["en" => "datatable-1"]],
        ["val" => 2, "name" => ["en" => "datatable-2"]],
    ])
    ->onChange('select2', route('select2-options-route'));

$datatable->input("select2")->select("name.en");

12. dropzone Method

use this method to make drag and drop files input.

this method accepts dropzone attributes.

in the edit form when dropzone is multiple and you delete any file from the dropzone you will get the values(ids) of those files in the update request in request key starts with remove_ then the input name.

$datatable->input("image")->dropzone([
    // "idColumn" => "multiple_images.id", // the column name to set the values of the deleted images
    // "path" => "/images", // path to be set before the db image path
    "multiple" => true, // default is false
    "maxFiles" => 6,
    "maxFileSize" => 2 * 1024 * 1024, //2MB
    "acceptedFiles" => 'jpg,mp4',
    // "addDownloadinks" => true, // default is true
    // "addRemoveLinks" => true, // default is true
    // "addFileName" => true, // default is true
    // "addFileSize" => true, // default is true
    // "customeMaxFilesMsg" => 'You can\'t upload more than 6 files',
    // "customeMaxFileSizeMsg" => 'Sorry, but max file size must be 2MB',
    // "customeAcceptedFilesMsg" => 'Sorry, but allowed extensions are ',
    // "removeMessageAfter" => 5000, // time || false  default 2500 ms,
    // "notFoundFileCallBack" => "404.jpg",
    // "overLayMessage" => "Drop Here",
]);

13. checkbox Method

you can use this method to make a checkbox.

This method accepts two arguments. The first is the checked value of the checkbox which is true by default and the second is the unchecked value of the checkbox which is false by default.

$datatable->input("checkbox")->checkbox(1, 0);

14. radio Method

you can use this method to create radio buttons, this method accepts one argument which will be the value of that radio button.

$datatable->input("radio")->radio(1)->label("Choice 1");
$datatable->input("radio")->radio(2)->label("Choice 2");
$datatable->input("radio")->radio(3)->label("Choice 3");