Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to customize the form builder Schemata #195

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ And more on the way.

[![bolt-pro](https://larazeus.com/images/bolt-pro-ad.png)](https://larazeus.com/bolt-pro)

[![bolt-preset](https://larazeus.com/images/bolt-preset-ad.png)](https://larazeus.com/bolt-preset)

## Overview
[read more](https://larazeus.com/docs/bolt/v1/overview) about the idea and how Bolt works.

Expand Down
23 changes: 23 additions & 0 deletions docs/advanced/custom-schemata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Custom Schemata
weight: 7
---

the trait `Schemata` is the heart of the form builder, and now you can customize it to your liking.

> **Note**\
> This is an advanced feature; please use it only when necessary since you have to mainline it manually with every update for Bolt.

### First, copy the trait to your app:

copy the trait from `\LaraZeus\Bolt\Concerns` to your app, let say: `\App\Zeus\Bolt\Concerns`

### call the trait in a service provider

in your register method of your `AppServiceProvider` add the following:

```php
\LaraZeus\Bolt\Filament\Resources\FormResource::getBoltFormSchemaUsing(fn(): array => \App\Zeus\Bolt\Concerns\Schemata::getMainFormSchema());
```

You're done. Customize the form builder to fit your needs. Remember to keep an eye on any changes in future updates so that you will avoid breaking changes.
36 changes: 36 additions & 0 deletions docs/bolt-preset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Bolt Preset
weight: 1001
---


## Zeus Bolt Preset

Create Forms with pre defined templates

## Available Sets

🔥 Support Ticket
🔥 Contact Form

### Get Bolt Preset from [here](https://larazeus.com/bolt-preset)

## Installation

To install bolt preset, you only need to require it in your composer by running the command:

```bash
composer require lara-zeus/bolt-preset
```

and that is all :).

you will get more details after you purchasing the package.

## Configuration

if you want to disable the preset button, add this to `zeus-bolt` config file:

```php
'show_presets' => false,
```
18 changes: 15 additions & 3 deletions docs/bolt-pro.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ Get additional fields for bolt. more options to build professional forms
- 🔥 Icon Picker, allow your users pick an icon!
- 🔥 Image Picker, allow users to pick an image.
- 🔥 Dynamic Textbox, allow users to add multiple text values
- 🔥 Signature Pad, collect users signature
- 🔥 terms and conditions
- 🔥 Signature Pad, collect users signature
- 🔥 terms and conditions with custom URLs
- 🔥 Advanced widgets and stats
- 🔥 Forms API
- 🔥 Custom colors and branding per form

### Get Bolt Pro from [here](https://larazeus.com/bolt-pro)

Expand All @@ -30,4 +33,13 @@ composer require lara-zeus/bolt-pro

and that is all :).

you will get more details after you purchasing the package.
you will get more details after you purchasing the package.

## Configuration

if you want to disable the preset button, add this to `zeus-bolt` config file:

```php
'allow_design' => false,
```

2 changes: 2 additions & 0 deletions docs/filament.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Bolt is a form builder for your users, with so many use cases included a UI for

[![bolt-pro](https://larazeus.com/images/bolt-pro-ad.png)](https://larazeus.com/bolt-pro)

[![bolt-preset](https://larazeus.com/images/bolt-preset-ad.png)](https://larazeus.com/bolt-preset)

## More Details
**✨ to learn more about Bolt the form builder, please visit:**

Expand Down
2 changes: 2 additions & 0 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ For example, you can use it as a job board, appointments, ticketing, survey, and

[![bolt-pro](https://larazeus.com/images/bolt-pro-ad.png)](https://larazeus.com/bolt-pro)

[![bolt-preset](https://larazeus.com/images/bolt-preset-ad.png)](https://larazeus.com/bolt-preset)

## Support

Available support channels:
Expand Down
15 changes: 14 additions & 1 deletion src/Filament/Resources/FormResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LaraZeus\Bolt\Filament\Resources;

use Closure;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Infolists\Components\IconEntry;
Expand Down Expand Up @@ -42,6 +43,8 @@ class FormResource extends BoltResource

protected static ?string $recordTitleAttribute = 'name';

protected static Closure | array | null $boltFormSchema = null;

public static function getModel(): string
{
return BoltPlugin::getModel('Form');
Expand Down Expand Up @@ -98,7 +101,17 @@ public static function infolist(Infolist $infolist): Infolist

public static function form(Form $form): Form
{
return $form->schema(static::getMainFormSchema());
return $form->schema(static::$boltFormSchema ?? static::getMainFormSchema());
}

public function getBoltFormSchema(): array | Closure | null
{
return static::$boltFormSchema;
}

public static function getBoltFormSchemaUsing(array | Closure | null $form): void
{
static::$boltFormSchema = $form;
}

public static function table(Table $table): Table
Expand Down