From 520c1d0a62fd6c55da39dcb49ccd81e6036778d7 Mon Sep 17 00:00:00 2001 From: philipp lang <philipp@aweos.de> Date: Fri, 28 Mar 2025 00:49:26 +0100 Subject: [PATCH] Add id to form elements instead of uuid --- app/View/Form/Editor.php | 5 ++--- app/View/Form/Lever.php | 5 ++--- app/View/Form/Select.php | 5 ++--- app/View/Form/Text.php | 7 +++---- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/View/Form/Editor.php b/app/View/Form/Editor.php index 8a608370..45c82ddf 100644 --- a/app/View/Form/Editor.php +++ b/app/View/Form/Editor.php @@ -10,16 +10,15 @@ class Editor extends Component use HasFormDimensions; - public string $id; - public function __construct( public string $name, public string $size = 'default', public ?string $hint = null, public bool $required = false, public string $label = '', + public string $id = '' ) { - $this->id = str()->uuid()->toString(); + $this->id = $this->id ? $this->id : $this->name; } public function render() diff --git a/app/View/Form/Lever.php b/app/View/Form/Lever.php index 7c0a3ed0..4afa37ec 100644 --- a/app/View/Form/Lever.php +++ b/app/View/Form/Lever.php @@ -10,8 +10,6 @@ class Lever extends Component use HasFormDimensions; - public string $id; - public function __construct( public string $name, public string $size = 'default', @@ -20,8 +18,9 @@ class Lever extends Component public bool $disabled = false, public bool $required = false, public string $label = '', + public string $id = '' ) { - $this->id = str()->uuid()->toString(); + $this->id = $this->id ? $this->id : $this->name; } public function render() diff --git a/app/View/Form/Select.php b/app/View/Form/Select.php index 45317eaf..b895498c 100644 --- a/app/View/Form/Select.php +++ b/app/View/Form/Select.php @@ -10,8 +10,6 @@ class Select extends Component use HasFormDimensions; - public string $id; - public function __construct( public string $name, public string $size = 'default', @@ -20,8 +18,9 @@ class Select extends Component public string $label = '', public $options = [], public bool $disabled = false, + public string $id = '' ) { - $this->id = str()->uuid()->toString(); + $this->id = $this->id ? $this->id : $this->name; } public function render() diff --git a/app/View/Form/Text.php b/app/View/Form/Text.php index 1f274277..713695b6 100644 --- a/app/View/Form/Text.php +++ b/app/View/Form/Text.php @@ -10,17 +10,16 @@ class Text extends Component use HasFormDimensions; - public string $id; - public function __construct( public string $name, public string $size = 'default', public ?string $hint = null, public bool $required = false, public string $label = '', - public string $type = 'text' + public string $type = 'text', + public string $id = '' ) { - $this->id = str()->uuid()->toString(); + $this->id = $this->id ? $this->id : $this->name; } public function render()