Skip to content

Commit 1dbe81c

Browse files
Fix bug missing ID
1 parent 6c535ca commit 1dbe81c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Supports/FormBuilder.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ public function input($type, $name, $value = null, $options = []): HtmlString
220220
// when creating the HTML element. Then, we will return the entire input.
221221
$merge = compact('type', 'value', 'id');
222222

223+
if ($id === null || $id === '') {
224+
unset($merge['id']);
225+
}
226+
227+
if ($value === null || $value === '') {
228+
unset($merge['value']);
229+
}
230+
223231
$options = array_merge($options, $merge);
224232

225233
return $this->toHtmlString('<input' . $this->html->attributes($options) . '>');
@@ -231,7 +239,7 @@ public function getIdAttribute($name, $attributes): string
231239
return $attributes['id'];
232240
}
233241

234-
if (in_array($name, $this->labels)) {
242+
if (empty($this->labels)) {
235243
return $name;
236244
}
237245

0 commit comments

Comments
 (0)