8000 Merge pull request #255 from jiwom/patch-1 · yajra/laravel-datatables-html@9374b32 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9374b32

Browse files
authored
Merge pull request #255 from jiwom/patch-1
feat: Add required functionality
2 parents bfd5db4 + f6020cf commit 9374b32

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Html/Editor/Fields/Field.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,4 +387,17 @@ public function className(string $className): static
387387

388388
return $this;
389389
}
390+
391+
/**
392+
* Add a format to indicate if a field is required.
393+
*
394+
* @return $this
395+
*/
396+
public function required(bool $required = true): static
397+
{
398+
$requiredFieldHtml = $required ? '<span class="text-red-500">*</span>' : '';
399+
$label = $this->get('label');
400+
401+
return $this->label(($label ?? '').' '.$requiredFieldHtml);
402+
}
390403
}

0 commit comments

Comments
 (0)
0