Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix for #42
  • Loading branch information
pascalbaljet committed Jan 4, 2021
commit 868535d5b0969d82c5757fa8571fc3aa44a8ba8f
12 changes: 11 additions & 1 deletion src/Components/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,19 @@ public function id(): string
}

if ($this->name) {
return $this->id = "auto_id_" . $this->name;
return $this->id = $this->generateIdByName();
}

return $this->id = Str::random(4);
}

/**
* Generates an ID by the name attribute.
*
* @return string
*/
protected function generateIdByName(): string
{
return "auto_id_" . $this->name;
}
}
10 changes: 10 additions & 0 deletions src/Components/FormCheckbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ public function __construct(
$this->checked = is_null($boundValue) ? $default : $boundValue;
}
}

/**
* Generates an ID by the name and value attributes.
*
* @return string
*/
protected function generateIdByName(): string
{
return "auto_id_" . $this->name . "_" . $this->value;
}
}
10 changes: 10 additions & 0 deletions src/Components/FormRadio.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ public function __construct(
$this->checked = (is_null($boundValue) ? $default : $boundValue) == $this->value;
}
}

/**
* Generates an ID by the name and value attributes.
*
* @return string
*/
protected function generateIdByName(): string
{
return "auto_id_" . $this->name . "_" . $this->value;
}
}