Skip to content

Commit 41e07e1

Browse files
authored
Merge pull request #3779 from Laravel-Backpack/required-repeatable-fields
fix required repeatable fields
2 parents ada0667 + f3b9fee commit 41e07e1

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/public/packages/backpack/crud/css/form.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
*/
66

7-
.form-group.required label:not(:empty):not(.form-check-label)::after {
7+
.form-group.required > label:not(:empty):not(.form-check-label)::after {
88
content: ' *';
99
color: #ff0000;
1010
}

src/resources/views/crud/fields/inc/wrapper_start.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
}
99
// if the field is required in the FormRequest, it should have an asterisk
1010
$required = (isset($action) && $crud->isRequired($field['name'], $action)) ? ' required' : '';
11-
11+
1212
// if the developer has intentionally set the required attribute on the field
1313
// forget whatever is in the FormRequest, do what the developer wants
14-
$required = (isset($field['showAsterisk'])) ? ($field['showAsterisk'] ? ' required' : '') : $required;
15-
14+
$required = isset($field['showAsterisk']) ? ($field['showAsterisk'] ? ' required' : '') : $required;
15+
1616
$field['wrapper']['class'] = $field['wrapper']['class'] ?? "form-group col-sm-12";
1717
$field['wrapper']['class'] = $field['wrapper']['class'].$required;
1818
$field['wrapper']['element'] = $field['wrapper']['element'] ?? 'div';

src/resources/views/crud/fields/repeatable.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
$subfield = $crud->makeSureFieldHasNecessaryAttributes($subfield);
5454
$fieldViewNamespace = $subfield['view_namespace'] ?? 'crud::fields';
5555
$fieldViewPath = $fieldViewNamespace.'.'.$subfield['type'];
56-
$subfield['showAsterisk'] = false;
5756
@endphp
5857

5958
@include($fieldViewPath, ['field' => $subfield])

src/resources/views/crud/form_content.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222

2323
<!-- CRUD FORM CONTENT - crud_fields_styles stack -->
2424
@stack('crud_fields_styles')
25+
26+
{{-- Temporary fix on 4.1 --}}
27+
<style>
28+
.form-group.required label:not(:empty):not(.form-check-label)::after {
29+
content: '';
30+
}
31+
.form-group.required > label:not(:empty):not(.form-check-label)::after {
32+
content: ' *';
33+
color: #ff0000;
34+
}
35+
</style>
2536
@endsection
2637

2738
@section('after_scripts')

0 commit comments

Comments
 (0)