Skip to content

Commit

Permalink
HTML option for buttons. Completed configuration documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
drsdre committed Nov 10, 2015
1 parent 8df3746 commit e68379a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Yii2 Wizard Widget
==================
Multi step wizard widget using tabs to guide a user through steps to complete a task. Based on the Form wizard (using tabs) from lukepzak (see http://bootsnipp.com/snippets/featured/form-wizard-using-tabs).


Installation
------------

Expand All @@ -22,10 +23,40 @@ or add
to the require section of your `composer.json` file.


Wizard configuration
--------------------

- `id`: *string* html id of the wizard widget
- `steps`: *array* definition of the wizard steps. Array key will be used as the hyperlinks to the steps.

Each step can have the following parameters:
- `title`: *string required* title of the step (shown when hoovering over step icon)
- `icon`: *string required* step icon code (see Glyphicon or Font awesome codes)
- `content`: *string required* HTML content of the step page
- `skippable`: *boolean optional* allow to skip over a step
- `buttons`: *array optional* configuration of the buttons per step
- `complete_content`: *string optional* the HTML content of a complete step
- `start_step`: *string optional* the starting step when wizard is initialized

In each step four different buttons can be configured (display of a button is dependent on position of the step in the sequence):
- `previous`: (not shown on first step)
- `next`: (not shown on last step)
- `skip`: (shown when skippable is set)
- `save`: (shown on the last step)

Each button can be configured with:
- `title`: *string optional* title as shown in the button
- `options`: *array optional* of HTML options (see [Yii2 HTML helper documentation](http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#button()-detail))

or

- `html`: *string optional* add your own button definition with HTML code (for example to save data after a step)


Usage
-----

Once the extension is installed, simply use it in your code by :
Once the extension is installed, use it in your code like :

```php
<?php
Expand Down
4 changes: 3 additions & 1 deletion WizardWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ protected function navButton($button_type, $step, $button_id) {
}

// Display button
if (isset($step['buttons'][$button_type]['title'])) {
if (isset($step['buttons'][$button_type]['html'])) {
return $step['buttons'][$button_type]['html'];
} elseif (isset($step['buttons'][$button_type]['title'])) {
return Html::button($step['buttons'][ $button_type ]['title'], $options);
} else {
return Html::button($this->default_buttons[ $button_type ]['title'], $options);
Expand Down

0 comments on commit e68379a

Please sign in to comment.