@@ -499,8 +499,8 @@ public function checkboxElement(
499
499
array $ options = []
500
500
) {
501
501
$ wrapperClass = $ inline ? 'form-check form-check-inline ' : 'form-check ' ;
502
- $ labelOptions = ['class ' => 'form-check-label ' ];
503
502
$ label = $ this ->getLabelTitle ($ label , $ name , $ options ) ?: '' ;
503
+ $ labelOptions = ['class ' => 'form-check-label ' ];
504
504
505
505
if ( ! isset ($ options ['class ' ])) {
506
506
$ options ['class ' ] = 'form-check-input ' ;
@@ -511,8 +511,8 @@ public function checkboxElement(
511
511
}
512
512
513
513
$ options ['class ' ] = trim ($ options ['class ' ] . ' ' . $ this ->getFieldErrorClass ($ name ));
514
- $ label = ($ label !== null ? '<label ' . $ this ->html ->attributes ($ labelOptions ) . '> ' . $ label . '</label> ' : '' );
515
514
515
+ $ label = ($ label !== null ? $ this ->form ->label ($ name , $ label , $ labelOptions ) : '' );
516
516
$ inputElement = $ this ->form ->checkbox ($ name , $ value , $ checked , $ options );
517
517
$ labelElement = $ inputElement . $ label . $ this ->getFieldError ($ name );
518
518
@@ -609,8 +609,8 @@ public function radioElement(
609
609
) {
610
610
$ wrapperClass = $ inline ? 'form-check form-check-inline ' : 'form-check ' ;
611
611
$ label = $ this ->getLabelTitle ($ label , $ name , $ options ) ?: '' ;
612
+ $ labelOptions = ['class ' => 'form-check-label ' ];
612
613
$ displayError = ! Arr::exists ($ options , 'no-error ' );
613
-
614
614
$ options = Arr::except ($ options , 'no-error ' );
615
615
616
616
$ options ['class ' ] = 'form-check-input ' . (isset ($ options ['class ' ]) ? (' ' . $ options ['class ' ]) : '' );
@@ -620,9 +620,8 @@ public function radioElement(
620
620
}
621
621
622
622
$ options ['class ' ] = $ options ['class ' ] . ($ displayError ? (' ' . $ this ->getFieldErrorClass ($ name )) : '' );
623
- $ labelOptions = ['class ' => 'form-check-label ' , 'for ' => $ this ->form ->getIdAttribute ($ name , $ options )];
624
- $ label = ($ label !== null ? '<label ' . $ this ->html ->attributes ($ labelOptions ) . '> ' . $ label . '</label> ' : '' );
625
623
624
+ $ label = ($ label !== null ? $ this ->form ->label (Arr::get ($ options , 'id ' ) ?: $ name , $ label , $ labelOptions ) : '' );
626
625
$ inputElement = $ this ->form ->radio ($ name , $ value , $ checked , $ options );
627
626
$ labelElement = $ inputElement . $ label . ($ displayError ? $ this ->getFieldError ($ name ) : '' );
628
627
@@ -653,13 +652,14 @@ public function radios(
653
652
$ elements = '' ;
654
653
$ label = $ this ->getLabelTitle ($ label , $ name , $ options );
655
654
$ radioOptions = array_merge (['no-error ' => true ], $ options );
655
+ $ index = 0 ;
656
656
657
657
Arr::forget ($ radioOptions , 'required ' );
658
658
659
659
foreach ($ choices as $ value => $ choiceLabel ) {
660
660
$ checked = $ value === $ checkedValue ;
661
661
662
- $ elements .= $ this ->radioElement ($ name , $ choiceLabel , $ value , $ checked , $ inline , $ radioOptions );
662
+ $ elements .= $ this ->radioElement ($ name , $ choiceLabel , $ value , $ checked , $ inline , $ radioOptions + [ ' id ' => $ name . ++ $ index ] );
663
663
}
664
664
665
665
$ comment = $ this ->getComment ($ options );
0 commit comments