CMS add-article (chiangmai, where-else): validate sub-categories by name instead of duplicate id so any single sub-category can be chosen without forcing People

This commit is contained in:
kurogeek committed 2026-10-26 05:37:20 +00:00
1 parent 225578a7ab
commit fdb71d61c7
2 files changed
+4 -4

No files matched your search

@@ -166,7 +166,7 @@
<label
class="form-check form-check-custom form-check-inline form-check-solid me-5 {{ $errors->has('sub_categories') ? 'is-invalid' : '' }}">
<input class="form-check-input" name="sub_categories[]"
id="sub_categories" type="checkbox" value="{{ $item->id }}"
type="checkbox" value="{{ $item->id }}"
{{ in_array($item->id, old('sub_categories', [])) ? 'checked' : '' }}>
<span class="fw-semibold ps-2 fs-6">
{{ $item->name . '(' . $item->name_en . ')' }}
@@ -542,7 +542,7 @@
}
// categories
const subCate = $('#sub_categories');
const subCate = $('input[name="sub_categories[]"]');
const anySelected = Array.from(subCate).some(checkbox => checkbox.checked);
if (!anySelected) {
alertFail('Notice', "Sub Categories is required");