Add TypeSwitch class and enhance attribute handling

Introduced a new `TypeSwitch` class to manage input type switch fields for forms, allowing simplified creation of toggle switches or binary options. Enhanced attribute handling in `formattributes.php` to conditionally remove the `checked` attribute only if not explicitly specified. Updated framework to include the new `TypeSwitch` class.
This commit is contained in:
stephan.kasdorf
2025-07-14 12:20:09 +02:00
parent 17166b8b6c
commit 157016ff35
4 changed files with 70 additions and 2 deletions

View File

@@ -59,7 +59,12 @@ class FormAttributes
$this->_element = str_replace(' ID', '', $this->_element);
$this->_element = str_replace(' CLASS', '', $this->_element);
$this->_element = str_replace(' enctype="ENCTYPE"', '', $this->_element);
$this->_element = str_replace(' checked="CHECKED"', '', $this->_element);
// Only remove checked attribute if it's not set in the attributes
if (!isset($attributes['checked']) || empty($attributes['checked']))
{
$this->_element = str_replace(' checked="CHECKED"', '', $this->_element);
$this->_element = str_replace(' CHECKED', '', $this->_element);
}
$this->_element = str_replace(' onsubmit="ONSUBMIT"', '', $this->_element);
$this->_element = str_replace(' onclick="ONCLICK"', '', $this->_element);
$this->_element = str_replace(' action="ACTION"', '', $this->_element);
@@ -85,8 +90,8 @@ class FormAttributes
$this->_element = str_replace(' method="METHOD"', '', $this->_element);
$this->_element = str_replace(' data-toggle="DATA-TOGGLE"', '', $this->_element);
$this->_element = str_replace(' SELECTED', '', $this->_element);
$this->_element = str_replace(' MULTIPLE', '', $this->_element);
$this->_element = str_replace(' CONTEXT', '', $this->_element);
$this->_element = str_replace(' CHECKED', '', $this->_element);
$this->_element = str_replace(' VALUE', '', $this->_element);
$this->_element = str_replace(' PATTERN', '', $this->_element);
$this->_element = str_replace('ANY', '', $this->_element);