PHP code example of tokarskimarcin / laravel-admin-ext-modal-form

1. Go to this page and download the library: Download tokarskimarcin/laravel-admin-ext-modal-form library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tokarskimarcin / laravel-admin-ext-modal-form example snippets


use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\Box;
use Encore\ModalForm\Form\ModalButton;

class HomeController {
    ...
    public function index(Content $content)
    {
        return $content->row(function (Row $row){
                   $row->column(4, function (Column $column){
                       $box = new Box();

                        //creates modal button with `Modal` title and generated route
                       $modalButton = new ModalButton('Modal', route('modal-form.create'));
                       
                       $box->content($modalButton);
                       $column->append($box);
                   });
               });
    }
}

//overrides classes of html button tag
$modalButton->setClass('btn-primary');

//appends class to existing once
$modalButton->addClass('btn-primary');

//retrieving settled classes as string
$modalButton->getClasses();

//sets href
$modalButton->setHref('url');

//returns settled hrefg
$modalButton->getHref();

use \Encore\ModalForm\Form\ModalForm;

new ModalForm(new Administrator(), function (ModalForm $form){
    $form->display('id', 'ID');
    
    //set action for proper submitting
    $form->setAction(route('modal-index-route'));
});

use \Encore\ModalForm\Facades\Modal;

Modal::form(new Administrator(), function (ModalForm $form){
    ...
});

$form->small();

$form->medium();

$form->large();