Fix forms on enhanced apps

This commit is contained in:
Chris Hunt
2025-07-11 16:18:13 +01:00
parent 8fb6438254
commit f197aeb013
4 changed files with 60 additions and 5 deletions

13
app/Facades/Form.php Normal file
View 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';
}
}

View File

@@ -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();
});

View 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
}

View File

@@ -5,20 +5,17 @@ use Illuminate\Support\Facades\Facade;
return [
'version' => '2.6.3',
'version' => '2.7.0',
'appsource' => env('APP_SOURCE', 'https://appslist.heimdall.site/'),
//'providers' => [
//App\Providers\FormMacroServiceProvider::class, // Add this line
//],
'aliases' => Facade::defaultAliases()->merge([
'EnhancedApps' => App\EnhancedApps::class,
'Form' => App\Facades\Form::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'SupportedApps' => App\SupportedApps::class,
'Yaml' => Symfony\Component\Yaml\Yaml::class,
'Form' => App\Providers\FormMacroServiceProvider::class
])->toArray(),
'auth_roles_enable' => (bool) env('AUTH_ROLES_ENABLE', false),