is7/yii2-smart-wizard

Yii2 smart-wizard.

Installs: 83

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Type:yii2-extension

v0.2.4 2021-09-20 14:49 UTC

This package is auto-updated.

Last update: 2024-03-20 20:31:49 UTC


README

Basic

<?php
use is7\smartwizard\Step;

echo Step::widget([
    'widgetOptions' => [
        'theme' => 'default',
        'showStepURLhash' => false,
        'autoAdjustHeight' => false,
    ],
    'items' => [
        1 => [
            'icon' => 'glyphicon glyphicon-user',
            'label' => 'Step - 1',
            'content' => 'Content 1'
        ],
        2 => [            
            'label' => 'Step - 2',
            'content' => '<h2>Content 2 </h2>'
        ],
    ],
]);

Advanced

<?php
use is7\smartwizard\Step;

echo Step::widget([
    'widgetOptions' => [
        'theme' => 'default',
        'showStepURLhash' => false,
        'autoAdjustHeight' => false,
    ],
    'extraButtons' => [
        'reset', // Reset Wizard
        'button' => [
            'icon' => 'glyphicon glyphicon-ok',
            'label' => 'Click',
            'class' => 'btn btn-primary',
            'visible' => 'final', // stepPosition string or stepNumber integer. Array supported, ex. [0,3,5] or ['first', 3]
            'onClick' => 'function() { alert("Clicked!"); }',
        ],
    ],
    'events' => [
        'leaveStep' => 'function(e, anchorObject, stepNumber, stepDirection) { alert(stepNumber); }',
    ],
    'progress' => [
        'enabled' => true,
        'label'   => true, // show label with percents
        'class'   => 'progress-bar-success',
    ],
    'items' => [
        1 => [
            'icon' => 'glyphicon glyphicon-user',
            'label' => 'Step - 1',
            'content' => 'Content 1'
        ],
        2 => [            
            'label' => 'Step - 2',
            'content' => '<h2>Content 2 </h2>'
        ],
    ],
]);

Form Validate

<?php $form = ActiveForm::begin([
    'enableClientValidation' => true,
]); 

echo Step::widget([
    'formId' => $form->id,
    'extraButtons' => [
        'submit',
        'reset',
    ],
    'widgetOptions' => [
        'theme' => 'default',
        'showStepURLhash' => false,
        'autoAdjustHeight' => false,        
    ],
    'items' => [
        1 => [
            'icon' => 'glyphicon glyphicon-info-sign',
            'label' => 'Step - 1 <br /><small>Information</small>',
            'content' => $this->render('_step-1', ['models' => $models, 'form' => $form])
        ],
        2 => [
            'icon' => 'glyphicon glyphicon-picture',
            'label' => 'Step - 2 <br /><small>Photo</small>',
            'content' => $this->render('_step-2', ['models' => $models, 'form' => $form])
        ],
        3 => [            
            'label' => 'Step - 3 <br /><small>Address</small>',
            'content' => $this->render('_step-3', ['models' => $models, 'form' => $form])
        ],
    ],
]);
?>

<?php ActiveForm::end(); ?>