|
@@ -75,26 +75,34 @@ class ListField extends Field
|
|
if ($this->validator) {
|
|
if ($this->validator) {
|
|
return $this->validator->call($this, $input);
|
|
return $this->validator->call($this, $input);
|
|
}
|
|
}
|
|
|
|
+
|
|
if (!is_string($this->column)) {
|
|
if (!is_string($this->column)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
$rules = $attributes = [];
|
|
$rules = $attributes = [];
|
|
if (!$fieldRules = $this->getRules()) {
|
|
if (!$fieldRules = $this->getRules()) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (!Arr::has($input, $this->column)) {
|
|
if (!Arr::has($input, $this->column)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
$rules["{$this->column}.values.*"] = $fieldRules;
|
|
$rules["{$this->column}.values.*"] = $fieldRules;
|
|
$attributes["{$this->column}.values.*"] = __('Value');
|
|
$attributes["{$this->column}.values.*"] = __('Value');
|
|
$rules["{$this->column}.values"][] = 'array';
|
|
$rules["{$this->column}.values"][] = 'array';
|
|
|
|
+
|
|
if (!is_null($this->max)) {
|
|
if (!is_null($this->max)) {
|
|
$rules["{$this->column}.values"][] = "max:$this->max";
|
|
$rules["{$this->column}.values"][] = "max:$this->max";
|
|
}
|
|
}
|
|
|
|
+
|
|
if (!is_null($this->min)) {
|
|
if (!is_null($this->min)) {
|
|
$rules["{$this->column}.values"][] = "min:$this->min";
|
|
$rules["{$this->column}.values"][] = "min:$this->min";
|
|
}
|
|
}
|
|
|
|
+
|
|
$attributes["{$this->column}.values"] = $this->label;
|
|
$attributes["{$this->column}.values"] = $this->label;
|
|
|
|
+
|
|
return validator($input, $rules, $this->getValidationMessages(), $attributes);
|
|
return validator($input, $rules, $this->getValidationMessages(), $attributes);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -103,7 +111,7 @@ class ListField extends Field
|
|
*/
|
|
*/
|
|
protected function setupScript()
|
|
protected function setupScript()
|
|
{
|
|
{
|
|
- $this->script = <<<SCRIPT
|
|
|
|
|
|
+ $this->script = <<<JS
|
|
$('.{$this->column}-add').on('click', function () {
|
|
$('.{$this->column}-add').on('click', function () {
|
|
var tpl = $('template.{$this->column}-tpl').html();
|
|
var tpl = $('template.{$this->column}-tpl').html();
|
|
$('tbody.list-{$this->column}-table').append(tpl);
|
|
$('tbody.list-{$this->column}-table').append(tpl);
|
|
@@ -111,7 +119,7 @@ $('.{$this->column}-add').on('click', function () {
|
|
$('tbody').on('click', '.{$this->column}-remove', function () {
|
|
$('tbody').on('click', '.{$this->column}-remove', function () {
|
|
$(this).closest('tr').remove();
|
|
$(this).closest('tr').remove();
|
|
});
|
|
});
|
|
-SCRIPT;
|
|
|
|
|
|
+JS;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -128,7 +136,9 @@ SCRIPT;
|
|
public function render()
|
|
public function render()
|
|
{
|
|
{
|
|
$this->setupScript();
|
|
$this->setupScript();
|
|
|
|
+
|
|
Admin::style('td .form-group {margin-bottom: 0 !important;}');
|
|
Admin::style('td .form-group {margin-bottom: 0 !important;}');
|
|
|
|
+
|
|
return parent::render();
|
|
return parent::render();
|
|
}
|
|
}
|
|
}
|
|
}
|