PHP code example of plesk / yii2-standalone-search-form

1. Go to this page and download the library: Download plesk/yii2-standalone-search-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/ */

    

plesk / yii2-standalone-search-form example snippets


[
    'components' => [
        'pjax' => [
            'class' => 'plesk\yii2pjax\Component',
        ],
    ],
]

use plesk\standalonesearchform\SearchForm;

echo SearchForm::widget([
    'model' => $searchModel,
    'fields' => [
        [
            'type' => 'widget',
            'attribute' => 'project_id',
            'width' => 'full-wide',
            'options' => [
                Chosen::className(),
                [
                    'items' => ArrayHelper::map($projects, 'id', 'name'),
                ]
            ]
        ],
        [
            'type' => 'checkbox',
            'attribute' => 'showCasesCount',
            'width' => 'full-wide',
            'options' => [[], false]
        ],
    ],
    'resultAreaPjaxOptions' => ['id' => 'result-area-pjax-grid', 'timeout' => 1000],
]);

use plesk\standalonesearchform\SearchForm;

echo SearchForm::widget([
    'model' => $searchModel,
    'collapse' => true,
    'fields' => [
        [
            'type' => 'widget',
            'attribute' => 'project_id',
            'width' => 'full-wide',
            'options' => [
                Chosen::className(),
                [
                    'items' => ArrayHelper::map($projects, 'id', 'name'),
                ]
            ]
        ],
        [
            'type' => 'widget',
            'attribute' => 'dateCreated',
            'width' => 'long',
            'range' => true,
            'options' => [
                DateTimePicker::className(),
            ]
        ],
    ],
    'resultAreaPjaxOptions' => ['id' => 'plesk-pjax-search-result', 'timeout' => 30000],
    'buttons' => [
        [
            'type' => 'submitButton',
            'options' => [
                'Search it!',
                ['class' => 'btn btn-primary'],
            ]
        ],
        [
            'type' => 'widget',
            'options' => [
                \app\components\widgets\clearButton\Widget::class,
                [
                    'content' => 'Clear it!',
                    'buttonOptions' => ['class' => 'btn btn-danger'],
                ],
            ]
        ]
    ],
]);
html
<head>
    
        $this->registerJs(
            '$(document).on(\'pjax:error\', function(event, xhr, textStatus, error, options) {
                pleskMessageBox.options.title = error;
                pleskMessageBox.alert(xhr.responseText);
            });'
        );