# Flow

## Setting up a flow

The Flow is defined by a JSON file. Name of the file can be anything, but **flow\.json** is a recommended name. Format of the data inside must be either JSON or JSONC. The flow\.json file will be picked up, loaded and exposed by the *Forms* module.&#x20;

{% tabs %}
{% tab title="Properties" %}

<table><thead><tr><th width="205">Name</th><th>Description</th><th>Default</th><th data-type="checkbox">Mandatory</th></tr></thead><tbody><tr><td><pre><code>name
</code></pre></td><td>Last part of the URL how to access the flow. Must be unique within the forms module.</td><td>N/A</td><td>true</td></tr><tr><td><pre><code>public
</code></pre></td><td>If flow can be accessed without any authentication (true/false). </td><td> false</td><td>false</td></tr><tr><td><pre><code>require_roles
</code></pre></td><td>Array of named roles user must have in order to access the flow, "one of"</td><td>Empty array: [] </td><td>false</td></tr><tr><td><pre><code>enable_progressbar
</code></pre></td><td>Should progress bar be visible (true/false). </td><td>true</td><td>false</td></tr><tr><td><pre><code>show_user_menu
</code></pre></td><td>Should user menu be visible (true/false). </td><td>true</td><td>false</td></tr><tr><td><pre><code>verbose_logs
</code></pre></td><td><p>Additional logging options.<br>Note. This can be added to forms module and will then be available in all flows.</p><pre class="language-json"><code class="lang-json">"flow",
"session"
</code></pre></td><td>Empty array []</td><td>false</td></tr><tr><td><pre><code>steps
</code></pre></td><td>Steps to include for the flow. Recommendation is using @include directive for better overview. </td><td>Empty array []</td><td>true</td></tr><tr><td><pre><code>pre_pipe
</code></pre></td><td>Pipe executed before first step.</td><td>N/A</td><td>false</td></tr><tr><td><pre><code>pipe    
</code></pre></td><td>Pipe to execute when last step is complete.</td><td>N/A</td><td>false</td></tr><tr><td><pre><code>summary
</code></pre></td><td>Step used after last regular step is executed with success. Used for user notification etc. Do not out any logic here.</td><td>N/A</td><td>false</td></tr><tr><td><pre><code>incomplete
</code></pre></td><td>Step used after last regular step is executed with with failure. Used for user notification etc. Do not out any logic here.</td><td>N/A</td><td>false</td></tr><tr><td><p></p><pre class="language-json"><code class="lang-json">buttons.
next_button
.enabled

</code></pre></td><td>Should next button be enabled (true/false).</td><td>true</td><td>false</td></tr><tr><td><pre><code>buttons.
next\_button.
text </code></pre></td><td>Text on "Next" button</td><td>Next</td><td>false</td></tr><tr><td><pre><code>buttons.
save\_button.
enabled </code></pre></td><td>Should save button be enabled (true/false).</td><td>true</td><td>false</td></tr><tr><td><pre><code>buttons.
save\_button.
text </code></pre></td><td>Text on "Save" button</td><td>Save</td><td>false</td></tr><tr><td><pre><code>buttons.
restart\_button.
enabled </code></pre></td><td>Should restart button be enabled (true/false).</td><td>true</td><td>false</td></tr><tr><td><pre><code>buttons.
restart\_button.
text </code></pre></td><td>Text on "Restart" button</td><td>Restart</td><td>false</td></tr></tbody></table>
{% endtab %}

{% tab title="Example" %}

```json
{
    "name": "demo",
    "public": false,
    "require_roles": [
        "role00"
    ],
    "enable_progressbar": false,
    "show_user_menu": true,
    "verbose_logs": [
        "flow",
        "session"
    ],
    "buttons": {
        "next_button": {
            "enabled": true,
            "text": "flow00.next_button"
        },
        "save_button": {
            "enabled": true,
            "text": "flow00.create_button"
        },
        "restart_button": {
            "enabled": true,
            "text": "flow00.restart_button"
        }
    },
    "steps": "@include:steps/*.json",
    "pre_pipe": "forms.flow00.pre_pipe",
    "pipe": "forms.flow00.finalize",
    "incomplete": "@include:incomplete.json",
    "summary": "@include:steps/summary.json"
}
```

{% endtab %}
{% endtabs %}

### Before step 1

Sometimes it is necessary to perform some kind of logic before first step is rendered. Typically used for validation and or collecting data reqired in step 1.&#x20;

For case like this use **pre\_pipe**.

In order to consume data in subsequent steps, make sure the pipe returns one item. Data in this item will be accessible using {{flow\.xxx}}
