PHP code example of lav45 / yii2-ajax-create

1. Go to this page and download the library: Download lav45/yii2-ajax-create 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/ */

    

lav45 / yii2-ajax-create example snippets


use lav45\widget\AjaxCreate;

AjaxCreate::begin();

echo Html::button('<span class="glyphicon glyphicon-plus"></span>', [
    'data-href' => Url::toRoute(['create']),
    'class' => 'btn btn-success',
]);

AjaxCreate::end();

class SiteController extends Controller
{
    public function actionCreate()
    {
        // ...
        return $this->renderAjax('create', [
            'model' => $model,
        ]);
    }
}

// views/site/_form.php

use yii\bootstrap\ActiveForm;

ActiveForm::$autoIdPrefix = 'a';

$form = ActiveForm::begin([
    'layout' => 'horizontal',
]);
// ...