mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-02-21 12:10:34 +09:00
Fix forms on enhanced apps
This commit is contained in:
13
app/Facades/Form.php
Normal file
13
app/Facades/Form.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class Form extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'custom-form';
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use App\Services\CustomFormBuilder;
|
||||
use Spatie\Html\Html;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -128,6 +130,10 @@ class AppServiceProvider extends ServiceProvider
|
||||
$this->app->register(IdeHelperServiceProvider::class);
|
||||
}
|
||||
|
||||
$this->app->singleton('custom-form', function ($app) {
|
||||
return new CustomFormBuilder($app->make(Html::class));
|
||||
});
|
||||
|
||||
$this->app->singleton('settings', function () {
|
||||
return new Setting();
|
||||
});
|
||||
|
||||
39
app/Services/CustomFormBuilder.php
Normal file
39
app/Services/CustomFormBuilder.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Spatie\Html\Html;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class CustomFormBuilder
|
||||
{
|
||||
protected Html $html;
|
||||
|
||||
public function __construct(Html $html)
|
||||
{
|
||||
$this->html = $html;
|
||||
}
|
||||
|
||||
public function text($name, $value = null, $options = [])
|
||||
{
|
||||
return new HtmlString(
|
||||
$this->html->input('text', $name, $value)->attributes($options)
|
||||
);
|
||||
}
|
||||
|
||||
public function select($name, $list = [], $selected = null, $options = [])
|
||||
{
|
||||
return new HtmlString(
|
||||
$this->html->select($name)->options($list, $selected)->attributes($options)
|
||||
);
|
||||
}
|
||||
|
||||
public function textarea($name, $value = null, $options = [])
|
||||
{
|
||||
return new HtmlString(
|
||||
$this->html->textarea($name, $value)->attributes($options)
|
||||
);
|
||||
}
|
||||
|
||||
// Add other methods as needed
|
||||
}
|
||||
Reference in New Issue
Block a user