11namespace Depage\HtmlForm\Elements;
13use Depage\HtmlForm\Abstracts;
84 parent::setDefaults();
87 $this->defaults[
'disabled'] =
false;
88 $this->defaults[
'required'] =
false;
107 $this->form->checkElementName(
$name);
109 $newElement = parent::addElement($type,
$name, $parameters);
111 if (!($newElement instanceof fieldset)) {
112 $this->form->updateInputValue(
$name);
127 if ($this->required) {
128 $classes .=
' required';
130 if ($this->disabled) {
131 $classes .=
' disabled';
133 if (!empty($this->
class)) {
134 $classes .=
' ' . $this->
htmlEscape($this->
class);
137 return trim($classes);
149 $renderedElements =
'';
150 $formName = $this->form->getName();
151 $label = $this->htmlLabel();
154 $htmlAttributes =
"id=\"{$formName}-{$this->name}\"";
155 $htmlAttributes .=
" name=\"{$this->name}\"";
158 if (!empty($classes)) {
159 $htmlAttributes .=
" class=\"" . $classes .
"\"";
163 foreach ($this->elementsAndHtml as $element) {
164 $renderedElements .= $element;
167 return "<fieldset {$htmlAttributes}>" .
168 "<legend><span>{$label}</span></legend>{$renderedElements}" .
container element base class
htmlDataAttributes()
Returns dataAttr escaped as attribute string.
htmlEscape(array|string $options=[])
Escapes HTML in strings and arrays of strings.
The fieldset class holds HTML-fieldset specific attributes and methods.
$required
HTML required attribute.
$disabled
HTML disabled attribute.
__toString()
Renders the fieldset to HTML code.
htmlClasses()
Returns string of the elements' HTML-classes, separated by spaces.
setDefaults()
collects initial values across subclasses.
addElement(string $type, string $name, array $parameters)
Generates sub-elements.