Skip to content

Commit f197aeb

Browse files
author
Chris Hunt
committed
Fix forms on enhanced apps
1 parent 8fb6438 commit f197aeb

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

app/Facades/Form.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class Form extends Facade
8+
{
9+
protected static function getFacadeAccessor()
10+
{
11+
return 'custom-form';
12+
}
13+
}

app/Providers/AppServiceProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Illuminate\Support\ServiceProvider;
1616
use Psr\Container\ContainerExceptionInterface;
1717
use Psr\Container\NotFoundExceptionInterface;
18+
use App\Services\CustomFormBuilder;
19+
use Spatie\Html\Html;
1820

1921
class AppServiceProvider extends ServiceProvider
2022
{
@@ -128,6 +130,10 @@ public function register(): void
128130
$this->app->register(IdeHelperServiceProvider::class);
129131
}
130132

133+
$this->app->singleton('custom-form', function ($app) {
134+
return new CustomFormBuilder($app->make(Html::class));
135+
});
136+
131137
$this->app->singleton('settings', function () {
132138
return new Setting();
133139
});

app/Services/CustomFormBuilder.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Services;
4+
5+
use Spatie\Html\Html;
6+
use Illuminate\Support\HtmlString;
7+
8+
class CustomFormBuilder
9+
{
10+
protected Html $html;
11+
12+
public function __construct(Html $html)
13+
{
14+
$this->html = $html;
15+
}
16+
17+
public function text($name, $value = null, $options = [])
18+
{
19+
return new HtmlString(
20+
$this->html->input('text', $name, $value)->attributes($options)
21+
);
22+
}
23+
24+
public function select($name, $list = [], $selected = null, $options = [])
25+
{
26+
return new HtmlString(
27+
$this->html->select($name)->options($list, $selected)->attributes($options)
28+
);
29+
}
30+
31+
public function textarea($name, $value = null, $options = [])
32+
{
33+
return new HtmlString(
34+
$this->html->textarea($name, $value)->attributes($options)
35+
);
36+
}
37+
38+
// Add other methods as needed
39+
}

config/app.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55

66
return [
77

8-
'version' => '2.6.3',
8+
'version' => '2.7.0',
99

1010
'appsource' => env('APP_SOURCE', 'https://appslist.heimdall.site/'),
1111

12-
//'providers' => [
13-
//App\Providers\FormMacroServiceProvider::class, // Add this line
14-
//],
1512

1613
'aliases' => Facade::defaultAliases()->merge([
1714
'EnhancedApps' => App\EnhancedApps::class,
15+
'Form' => App\Facades\Form::class,
1816
'Redis' => Illuminate\Support\Facades\Redis::class,
1917
'SupportedApps' => App\SupportedApps::class,
2018
'Yaml' => Symfony\Component\Yaml\Yaml::class,
21-
'Form' => App\Providers\FormMacroServiceProvider::class
2219
])->toArray(),
2320

2421
'auth_roles_enable' => (bool) env('AUTH_ROLES_ENABLE', false),

0 commit comments

Comments
 (0)