PHP code example of siripravi / yii2-smart-wizard
1. Go to this page and download the library: Download siripravi/yii2-smart-wizard 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/ */
siripravi / yii2-smart-wizard example snippets
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])
],
],
]);
ActiveForm::end();