Skip to content

Commit db5d3e7

Browse files
committed
Add boolean support for rows type columns
1 parent 4ad34f2 commit db5d3e7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Controllers/BaseController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ public function rows($columnId, $column)
509509

510510
if ($opt['type'] == 'string' || $opt['type'] == 'password' || $opt['type'] == 'date' || $opt['type'] == 'datetime' || $opt['type'] == 'number') {
511511
$response .= '<input class="' . ($opt['type'] == 'date' ? 'datepicker' : '') . ($opt['type'] == 'datetime' ? 'datetimepicker' : '') . '" type="' . ($opt['type'] == 'string' || $opt['type'] == 'date' || $opt['type'] == 'datetime' ? 'text' : $opt['type']) . '" name="' . $columnId . '_' . $columnId2 . '[]" data-column="' . $columnId . '_' . $columnId2 . '" placeholder="' . $this->locale('placeholder', $opt, '') . '">';
512+
} elseif ($opt['type'] == 'boolean') {
513+
$response .= '<input type="hidden" hidden-type="checkbox" name="' . $columnId . '_' . $columnId2 . '[]" data-column="' . $columnId . '_' . $columnId2 . '" value="0"><input type="checkbox" onclick="this.previousSibling.value=1-this.previousSibling.value">';
512514
} elseif ($opt['type'] == 'foreign') {
513515
$response .= $this->foreign($columnId . '_' . $columnId2 . '[]', $opt, false);
514516
} else {

src/js/model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,11 @@ function modelAddLine(slug, element, data, column) {
560560
});
561561
if (data) {
562562
for (n in data) {
563-
tr.find('INPUT[data-column=' + column + '_' + n + ']').val(data[n]);
563+
var e = tr.find('INPUT[data-column=' + column + '_' + n + ']');
564+
if (e.attr('hidden-type') == 'checkbox') {
565+
e.next().prop('checked', data[n] == true);
566+
}
567+
e.val(data[n]);
564568
tr.find('SELECT[data-column=' + column + '_' + n + ']').val(data[n]);
565569
}
566570
}

0 commit comments

Comments
 (0)