Skip to content

Commit

Permalink
Added parameter to start with a specific step ('start_step').
Browse files Browse the repository at this point in the history
  • Loading branch information
drsdre committed Oct 20, 2015
1 parent ba4d2bd commit 494920f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -58,6 +58,7 @@ $wizard_config = [
],
],
'complete_content' => "You are done!", // Optional final screen
'start_step' => 2,
];
?>

Expand Down
11 changes: 8 additions & 3 deletions WizardWidget.php
Expand Up @@ -39,6 +39,11 @@ class WizardWidget extends Widget {
*/
public $steps = [];

/**
* @var integer step number to start with (range 1 to number of defined steps)
*/
public $start_step = 1;

/**
* @var string optional final complete step content
*/
Expand All @@ -63,7 +68,7 @@ public function run() {

foreach ($this->steps as $id => $step) {

$wizard_line .= '<li role="presentation" class="'.($first?"active":"disabled").'">'.
$wizard_line .= '<li role="presentation" class="'.($id==($this->start_step-1)?"active":"disabled").'">'.
Html::a('<span class="round-tab"><i class="'.$step['icon'].'"></i></span>', '#step'.$id, [
'data-toggle' => 'tab',
'aria-controls' => 'step'.$id,
Expand All @@ -73,7 +78,7 @@ public function run() {
'</li>';

// Setup tab content (first tab is always active)
$tab_content .= '<div class="tab-pane '.($first?"active":"disabled").'" role="tabpanel" id="step'.$id.'">';
$tab_content .= '<div class="tab-pane '.($id==($this->start_step-1)?"active":"disabled").'" role="tabpanel" id="step'.$id.'">';
$tab_content .= $step['content'];

// Setup navigation buttons
Expand All @@ -97,7 +102,7 @@ public function run() {

$first = false;
}
// Add a complete step if defined
// Add a completed step if defined
if ($this->complete_content) {
$wizard_line .= '<li role="presentation" class="disabled">'.
Html::a('<span class="round-tab"><i class="glyphicon glyphicon-ok"></i></span>', '#complete', [
Expand Down

0 comments on commit 494920f

Please sign in to comment.