Skip to content

Commit

Permalink
Merge pull request #87 from lara-zeus/update-docs
Browse files Browse the repository at this point in the history
more docs
  • Loading branch information
atmonshi authored Jun 30, 2023
2 parents 193c89a + f7ebb0c commit 456224d
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 1 deletion.
15 changes: 15 additions & 0 deletions docs/conditional-visibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

---
title: Conditional Visibility
weight: 10
---

## Conditional Visibility

You can build your form with Conditional fields and show a field based on a specific option from another field.
check out [this form](https://demo.larazeus.com/bolt/feedback) for example.

## Known limitation
- currently, you can only set the conditional field for files with a data source (select, checkboxes ... etc.) since it's easier to validate against them; if we allow all the field types, it will run no complicated UI to manage different scenarios, for example with dates (before or after), and integers (higher or lower), and with text... I don't want to think about it :).
- you can select the Conditional field after saving the form. Otherwise, Bolt can't find the newly created fields.
- still testing them; let me know if you find any issues.
114 changes: 114 additions & 0 deletions docs/extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
title: Extensions
weight: 9
---

## Extensions

Bolt over a simple way to build your own application around the forms, with a simple interface, called `extensions` :

Extensions are hooks based classes that let you perform your logic around the forms or catch the submission and do more integrations with other apps or external APIs.
for example before showing the form, or after storing the data etc...

## Available Hooks:

- `canView`
before displaying the form, you can do some checks.

- `render`
what to show at the beginning of the form, you can return a view to show more info or instructors while filling out the form.

-`formComponents`
return an array of filament components to add them to the form in the frontend

- `store`
the store logic for the extension, insert to any DB or external API.

- `postStore`
this is typically used for sending only. It will be executed after saving the form

- `submittedRender`
this will show any info after saving the form, like a request number or more buttons and links


## Creating an Extension

create a class in your app with the following content:

>I will create a command later :)
```php

<?php

namespace App\Zeus\Extensions;

use Filament\Forms\Components\TextInput;
use LaraZeus\Bolt\Contracts\Extension;
use LaraZeus\Bolt\Models\Form;

class Items implements Extension
{
public function label(): string
{
return 'Ext Name';
}

public function canView(Form $form, array $data): bool|array|null
{
// abort_if ...
// get the ext app and return it back, so you can receive it in the render
// return [];
}

public function render(Form $form, array $data): string|null
{
// set any data and pas it to your view
// $data['items'] = ...

// return view();
}

public function formComponents(Form $form): array|null
{
return [
TextInput::make('extensions.order_number'),
];
}

public function store(Form $form, array $data): array|null
{
/*$model = Model::create([
'order_number' => $data['order_number'],
// ...
]);*/

// return these data to recive them after the form submitted
// $data['model'] = $model;

return $data;
}

public function postStore(Form $form, array $data): void
{
// send emails
// fire some events
}

public function SubmittedRender(Form $form, array $data): string|null
{
// return view()->with('data', $data);
}
}

```

## Enabling The Extension
in your `zeus-bolt` config file, add your extension to the array:
```php
'extensions' => [
\App\Zeus\Extensions\Items::class,
],
```

now when creating or editing a form, you will see the tab Extensions, and you can select any extension per form.
3 changes: 2 additions & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ included a UI for the frontend bilt with filament
- 🔥 confirmation message after submission per form
- 🔥 option for requiring login perform
- 🔥 limit submissions with one entry for a user (if auth is required only)
- 🔥 Conditional Visibility for fields.
- 🔥 Extensions
- 🔥 Available Fields:
- Text Input
- Select Menu
Expand Down Expand Up @@ -53,7 +55,6 @@ included a UI for the frontend bilt with filament
- 🔥 show the entries for the users
- 🔥 List all forms for the users


## Support
available support channels:
* open an issue on [GitHub](https://github.com/lara-zeus/bolt/issues)
Expand Down

0 comments on commit 456224d

Please sign in to comment.