Skip to content

Commit

Permalink
fix: select multiple detection not strict
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandhi11 committed Oct 31, 2023
1 parent beb14e9 commit fb4a9d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/Bootstrap4FormServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ function (
$selected = null,
array $selectAttributes = [],
): FormGroupBuilder {
if (is_null($selected) && in_array('multiple', $selectAttributes)) {
if (is_null($selected) &&
(
in_array('multiple', array_values($selectAttributes), true) ||
array_key_exists('multiple', $selectAttributes)
)
) {
$selected = Html::value($name) ?? [];
}

Expand Down Expand Up @@ -327,8 +332,7 @@ function (
*/
public static function addTabIndexIfReadonly(array $attributes): array
{
if (
(in_array('readonly', $attributes) || array_key_exists('readonly', $attributes)) &&
if ((in_array('readonly', $attributes) || array_key_exists('readonly', $attributes)) &&
!array_key_exists('tabIndex', $attributes)
) {
$attributes['tabIndex'] = -1;
Expand Down
4 changes: 3 additions & 1 deletion src/Support/FormGroupBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ public function select(
$selected,
)->attributes($this->parseInputOptions($selectAttributes)->all());

if (in_array('multiple', $selectAttributes)) {
if (in_array('multiple', array_values($selectAttributes), true) ||
array_key_exists('multiple', $selectAttributes)
) {
$this->input = $this->input->multiple();
}

Expand Down

0 comments on commit fb4a9d2

Please sign in to comment.