Represents label for a form field. If label is empty, field part will be hidden.
Form model:
final class CreateForm extends FormModel
{
public ?string $name = null;
public function getAttributeLabels(): array
{
return [
'name' => 'Full Name',
];
}
}
Widget:
echo Label::widget()->formAttribute($createForm, 'name');
Result will be:
<label for="createform-name">Full Name</label>