Skip to content

Commit

Permalink
support radio and checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed Nov 4, 2023
1 parent aee419d commit c004d7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion resources/views/components/matrix-choice.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
<tr>
<td class="p-2">{{ $rowValue }}</td>
@foreach($columnData as $columnKey => $columnValue)
@php
$supStatPath = ($pilColor === 'radio') ? $statePath.'.'.$rowKey : $statePath.'.'.$rowKey.'.'.$columnKey ;
@endphp
<td class="p-2 text-center">
<input
wire:key="{{ $id }}.{{ $rowKey }}"
wire:loading.attr="disabled"
{{ $applyStateBindingModifiers('wire:model') }}="{{ $statePath }}.{{$rowKey}}"
{{ $applyStateBindingModifiers('wire:model') }}="{{ $supStatPath }}"
value="{{ $columnKey }}"
type="{{ $pilColor }}"
class="mt-1 border-none bg-white shadow-sm ring-1 transition duration-75 checked:ring-0 focus:ring-2 focus:ring-offset-0 disabled:bg-gray-50 disabled:text-gray-50 disabled:checked:bg-current disabled:checked:text-gray-400 dark:bg-white/5 dark:disabled:bg-transparent dark:disabled:checked:bg-gray-600 text-primary-600 ring-gray-950/10 focus:ring-primary-600 checked:focus:ring-primary-500/50 dark:text-primary-500 dark:ring-white/20 dark:checked:bg-primary-500 dark:focus:ring-primary-500 dark:checked:focus:ring-primary-400/50 dark:disabled:ring-white/10"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function setUp(): void
$this->rules([
function () {
return function (string $attribute, mixed $value, Closure $fail) {
if (blank($value)) {
if (blank($value) || count($this->getRowData()) !== count($value)) {
$fail(__('required a selection for each row'));
}
foreach ($value as $val) {
Expand Down

0 comments on commit c004d7e

Please sign in to comment.