ソースを参照

update

update
jqh 5 年 前
コミット
7d6bc85902

+ 1 - 1
resources/views/form/hasmanytable.blade.php

@@ -34,7 +34,7 @@
                                 @continue
                             @endif
 
-                            <td>{!! $field->labelClass(['hidden'])->width(12, 0)->render() !!}</td>
+                            <td>{!! $field->setLabelClass(['hidden'])->width(12, 0)->render() !!}</td>
                         @endforeach
 
                         <td class="hidden">{!! $hidden !!}</td>

+ 2 - 2
src/Actions/Action.php

@@ -126,7 +126,7 @@ abstract class Action implements Renderable
     /**
      * @return string
      */
-    protected function elementClass()
+    protected function getElementClass()
     {
         return ltrim($this->selector(), '.');
     }
@@ -247,7 +247,7 @@ HTML;
      */
     protected function setupHtmlAttributes()
     {
-        $this->addHtmlClass($this->elementClass());
+        $this->addHtmlClass($this->getElementClass());
 
         $attributes = [
             'class' => $this->formatHtmlClasses(),

+ 3 - 3
src/Form/EmbeddedForm.php

@@ -246,9 +246,9 @@ class EmbeddedForm
             $elementClass = "{$this->column}_$jsonKey";
         }
 
-        $field->elementName($elementName)
-            ->errorKey($errorKey)
-            ->elementClass($elementClass);
+        $field->setElementName($elementName)
+            ->setErrorKey($errorKey)
+            ->setElementClass($elementClass);
 
         return $field;
     }

+ 68 - 46
src/Form/Field.php

@@ -315,17 +315,23 @@ class Field implements Renderable
      *
      * @author Edwin Hui
      */
-    public function elementName($name = null)
+    public function setElementName(string $name)
     {
-        if ($name === null) {
-            return $this->elementName ?: $this->formatName($this->column);
-        }
-
         $this->elementName = $name;
 
         return $this;
     }
 
+    /**
+     * Get form element name.
+     *
+     * @return array|mixed|string
+     */
+    public function getElementName()
+    {
+        return $this->elementName ?: $this->formatName($this->column);
+    }
+
     /**
      * Fill data to the field.
      *
@@ -488,23 +494,29 @@ class Field implements Renderable
     }
 
     /**
-     * Get or set key for error message.
+     * Set key for error message.
      *
      * @param string $key
      *
      * @return $this|string
      */
-    public function errorKey($key = null)
+    public function setErrorKey(string $key)
     {
-        if ($key === null) {
-            return $this->errorKey ?: $this->column;
-        }
-
         $this->errorKey = $key;
 
         return $this;
     }
 
+    /**
+     * Get key for error message.
+     *
+     * @return string
+     */
+    public function getErrorKey()
+    {
+        return $this->errorKey ?: $this->column;
+    }
+
     /**
      * Set or get value of the field.
      *
@@ -693,7 +705,7 @@ class Field implements Renderable
     public function required($isLabelAsterisked = true)
     {
         if ($isLabelAsterisked) {
-            $this->labelClass(['asterisk']);
+            $this->setLabelClass(['asterisk']);
         }
 
         $this->rules('required');
@@ -822,41 +834,47 @@ class Field implements Renderable
     /**
      * @return array
      */
-    public function viewElementClasses()
+    public function getViewElementClasses()
     {
         if ($this->horizontal) {
             return [
-                'label'      => "col-sm-{$this->width['label']} {$this->labelClass()}",
+                'label'      => "col-sm-{$this->width['label']} {$this->getLabelClass()}",
                 'field'      => "col-sm-{$this->width['field']}",
                 'form-group' => 'form-group ',
             ];
         }
 
-        return ['label' => $this->labelClass(), 'field' => '', 'form-group' => ''];
+        return ['label' => $this->getLabelClass(), 'field' => '', 'form-group' => ''];
     }
 
     /**
-     * Set form element class.
+     * Set element class.
      *
      * @param string|array $class
      *
-     * @return $this|array
+     * @return $this
      */
-    public function elementClass($class = null)
+    public function setElementClass($class)
     {
-        if ($class === null) {
-            if (! $this->elementClass) {
-                $name = $this->elementName ?: $this->formatName($this->column);
+        $this->elementClass = array_merge($this->elementClass, (array) $class);
 
-                $this->elementClass = (array) str_replace(['[', ']'], '_', $name);
-            }
+        return $this;
+    }
 
-            return $this->elementClass;
-        }
+    /**
+     * Get element class.
+     *
+     * @return array
+     */
+    public function getElementClass()
+    {
+        if (! $this->elementClass) {
+            $name = $this->elementName ?: $this->formatName($this->column);
 
-        $this->elementClass = array_merge($this->elementClass, (array) $class);
+            $this->elementClass = (array) str_replace(['[', ']'], '_', $name);
+        }
 
-        return $this;
+        return $this->elementClass;
     }
 
     /**
@@ -864,9 +882,9 @@ class Field implements Renderable
      *
      * @return mixed
      */
-    protected function elementClassString()
+    protected function getElementClassString()
     {
-        $elementClass = $this->elementClass();
+        $elementClass = $this->getElementClass();
 
         if (Arr::isAssoc($elementClass)) {
             $classes = [];
@@ -886,11 +904,11 @@ class Field implements Renderable
      *
      * @return string|array
      */
-    protected function elementClassSelector()
+    protected function getElementClassSelector()
     {
-        $elementClass = $this->elementClass();
+        $elementClass = $this->getElementClass();
 
-        $formId = $this->formElementId();
+        $formId = $this->getFormElementId();
         $formId = $formId ? '#'.$formId : '';
 
         if (Arr::isAssoc($elementClass)) {
@@ -926,7 +944,7 @@ class Field implements Renderable
     /**
      * @return string|null
      */
-    protected function formElementId()
+    protected function getFormElementId()
     {
         return $this->form ? $this->form->getElementId() : null;
     }
@@ -991,12 +1009,8 @@ class Field implements Renderable
      *
      * @return $this|string
      */
-    public function labelClass($labelClass = null, bool $append = true)
+    public function setLabelClass($labelClass, bool $append = true)
     {
-        if ($labelClass === null) {
-            return implode(' ', $this->labelClass);
-        }
-
         $this->labelClass = $append
             ? array_unique(array_merge($this->labelClass, (array) $labelClass))
             : (array) $labelClass;
@@ -1004,6 +1018,14 @@ class Field implements Renderable
         return $this;
     }
 
+    /**
+     * @return string
+     */
+    public function getLabelClass()
+    {
+        return implode(' ', $this->labelClass);
+    }
+
     /**
      * Get the view variables of this field.
      *
@@ -1013,18 +1035,18 @@ class Field implements Renderable
     {
         return array_merge($this->variables, [
             'id'          => $this->id,
-            'name'        => $this->elementName(),
+            'name'        => $this->getElementName(),
             'help'        => $this->help,
-            'class'       => $this->elementClassString(),
+            'class'       => $this->getElementClassString(),
             'value'       => $this->value(),
             'label'       => $this->label,
-            'viewClass'   => $this->viewElementClasses(),
+            'viewClass'   => $this->getViewElementClasses(),
             'column'      => $this->column,
-            'errorKey'    => $this->errorKey(),
+            'errorKey'    => $this->getErrorKey(),
             'attributes'  => $this->formatAttributes(),
             'placeholder' => $this->placeholder(),
             'disabled'    => $this->attributes['disabled'] ?? false,
-            'formId'      => $this->formElementId(),
+            'formId'      => $this->getFormElementId(),
         ]);
     }
 
@@ -1033,7 +1055,7 @@ class Field implements Renderable
      *
      * @return string
      */
-    public function getView()
+    public function view()
     {
         return $this->view ?: 'admin::form.'.strtolower(class_basename(static::class));
     }
@@ -1043,7 +1065,7 @@ class Field implements Renderable
      *
      * @return string
      */
-    public function view($view)
+    public function setView($view)
     {
         $this->view = $view;
 
@@ -1116,7 +1138,7 @@ class Field implements Renderable
 
         Admin::script($this->script);
 
-        return view($this->getView(), $this->variables());
+        return view($this->view(), $this->variables());
     }
 
     /**

+ 1 - 1
src/Form/Field/BootstrapFile.php

@@ -187,7 +187,7 @@ class BootstrapFile extends Field
         $options = json_encode($this->options);
 
         $this->script = <<<JS
-$("{$this->elementClassSelector()}").fileinput({$options});
+$("{$this->getElementClassSelector()}").fileinput({$options});
 JS;
 
         return parent::render();

+ 1 - 1
src/Form/Field/BootstrapMultipleFile.php

@@ -227,7 +227,7 @@ class BootstrapMultipleFile extends Field
         $options = json_encode($this->options);
 
         $this->script = <<<JS
-$("{$this->elementClassSelector()}").fileinput({$options});
+$("{$this->getElementClassSelector()}").fileinput({$options});
 JS;
 
         return parent::render();

+ 1 - 1
src/Form/Field/Button.php

@@ -18,7 +18,7 @@ class Button extends Field
     public function on($event, $callback)
     {
         $this->script = <<<JS
-        $('{$this->elementClassSelector()}').on('$event', function() {
+        $('{$this->getElementClassSelector()}').on('$event', function() {
             $callback
         });
 JS;

+ 1 - 1
src/Form/Field/Color.php

@@ -51,7 +51,7 @@ class Color extends Text
     {
         $options = json_encode($this->options);
 
-        $this->script = "$('{$this->elementClassSelector()}').parent().colorpicker($options);";
+        $this->script = "$('{$this->getElementClassSelector()}').parent().colorpicker($options);";
 
         $this->prepend('<i></i>')
             ->defaultAttribute('style', 'width: 200px');

+ 1 - 1
src/Form/Field/Date.php

@@ -30,7 +30,7 @@ class Date extends Text
         $this->options['locale'] = config('app.locale');
         $this->options['allowInputToggle'] = true;
 
-        $this->script = "$('{$this->elementClassSelector()}').parent().datetimepicker(".json_encode($this->options).');';
+        $this->script = "$('{$this->getElementClassSelector()}').parent().datetimepicker(".json_encode($this->options).');';
 
         $this->prepend('<i class="fa fa-calendar fa-fw"></i>')
             ->defaultAttribute('style', 'width: 200px');

+ 1 - 1
src/Form/Field/DateRange.php

@@ -44,7 +44,7 @@ class DateRange extends Field
         $startOptions = json_encode($this->options);
         $endOptions = json_encode($this->options + ['useCurrent' => false]);
 
-        $class = $this->elementClassSelector();
+        $class = $this->getElementClassSelector();
 
         $this->script = <<<JS
             $('{$class['start']}').datetimepicker($startOptions);

+ 1 - 1
src/Form/Field/HasMany.php

@@ -683,7 +683,7 @@ JS;
                 $hidden[] = $field->render();
             } else {
                 /* Hide label and set field width 100% */
-                $field->labelClass(['hidden']);
+                $field->setLabelClass(['hidden']);
                 $field->width(12, 0);
                 $fields[] = $field->render();
                 $headers[] = $field->label();

+ 1 - 1
src/Form/Field/Html.php

@@ -62,7 +62,7 @@ class Html extends Field
             return $this->html;
         }
 
-        $viewClass = $this->viewElementClasses();
+        $viewClass = $this->getViewElementClasses();
 
         return <<<EOT
 <div class="form-group">

+ 1 - 1
src/Form/Field/Icon.php

@@ -10,7 +10,7 @@ class Icon extends Text
     {
         $this->script = <<<JS
 setTimeout(function () {
-    $('{$this->elementClassSelector()}').iconpicker({placement:'bottomLeft'});
+    $('{$this->getElementClassSelector()}').iconpicker({placement:'bottomLeft'});
 }, 10);
 JS;
 

+ 1 - 1
src/Form/Field/KeyValue.php

@@ -74,7 +74,7 @@ class KeyValue extends Field
         $value = old($this->column, $this->value());
 
         $number = $value ? count($value) : 0;
-        $class = $this->elementClassString();
+        $class = $this->getElementClassString();
 
         $this->script = <<<JS
 (function () {

+ 1 - 1
src/Form/Field/Listbox.php

@@ -33,7 +33,7 @@ class Listbox extends MultipleSelect
         $settings = json_encode($settings);
 
         $this->script = <<<JS
-$("{$this->elementClassSelector()}").bootstrapDualListbox($settings);
+$("{$this->getElementClassSelector()}").bootstrapDualListbox($settings);
 JS;
 
         return parent::render();

+ 1 - 1
src/Form/Field/Number.php

@@ -14,7 +14,7 @@ class Number extends Text
 
         $this->script = <<<JS
 
-$('{$this->elementClassSelector()}:not(.initialized)')
+$('{$this->getElementClassSelector()}:not(.initialized)')
     .addClass('initialized')
     .bootstrapNumber({
         upClass: 'success',

+ 7 - 7
src/Form/Field/Select.php

@@ -100,8 +100,8 @@ class Select extends Field
         }
 
         $script = <<<JS
-$(document).off('change', "{$this->elementClassSelector()}");
-$(document).on('change', "{$this->elementClassSelector()}", function () {
+$(document).off('change', "{$this->getElementClassSelector()}");
+$(document).on('change', "{$this->getElementClassSelector()}", function () {
     var target = $(this).closest('.fields-group').find(".$class");
     $.get("$sourceUrl?q="+this.value, function (data) {
         target.find("option").remove();
@@ -152,8 +152,8 @@ var refreshOptions = function(url, target) {
     });
 };
 
-$(document).off('change', "{$this->elementClassSelector()}");
-$(document).on('change', "{$this->elementClassSelector()}", function () {
+$(document).off('change', "{$this->getElementClassSelector()}");
+$(document).on('change', "{$this->getElementClassSelector()}", function () {
     var _this = this;
     var promises = [];
 
@@ -244,7 +244,7 @@ JS;
 
 $.ajax($ajaxOptions).done(function(data) {
 
-  var select = $("{$this->elementClassSelector()}");
+  var select = $("{$this->getElementClassSelector()}");
 
   select.select2({
     data: data,
@@ -286,7 +286,7 @@ JS;
 
         $this->script = <<<JS
 
-$("{$this->elementClassSelector()}").select2({
+$("{$this->getElementClassSelector()}").select2({
   ajax: {
     url: "$url",
     dataType: 'json',
@@ -367,7 +367,7 @@ JS;
         $configs = json_encode($configs);
 
         if (empty($this->script)) {
-            $this->script = "$(\"{$this->elementClassSelector()}\").select2($configs);";
+            $this->script = "$(\"{$this->getElementClassSelector()}\").select2($configs);";
         }
 
         if ($this->options instanceof \Closure) {

+ 4 - 4
src/Form/Field/SelectResource.php

@@ -171,14 +171,14 @@ class SelectResource extends Field
         $lessThenLabel = trans('admin.selected_must_less_then', ['num' => $this->maxItem]);
         $selectedOptionsLabel = trans('admin.selected_options');
         $disabled = empty($this->attributes['disabled']) ? '' : 'disabled';
-        $containerId = $this->id.$this->formElementId();
+        $containerId = $this->id.$this->getFormElementId();
         $maxItem = (int) $this->maxItem;
 
         Admin::script(
             <<<JS
 LA.ResourceSelector({
     title: '{$label}',
-    column: "{$this->elementName()}",
+    column: "{$this->getElementName()}",
     source: '{$this->source}',
     selector: '#{$this->btnId}',
     maxItem: {$maxItem}, 
@@ -224,9 +224,9 @@ JS
         $name = $this->elementName ?: $this->formatName($this->column);
 
         $this->prepend('<i class="fa fa-long-arrow-up"></i>')
-            ->defaultAttribute('class', 'form-control '.$this->elementClassString())
+            ->defaultAttribute('class', 'form-control '.$this->getElementClassString())
             ->defaultAttribute('type', 'text')
-            ->defaultAttribute('id', $this->id.$this->formElementId())
+            ->defaultAttribute('id', $this->id.$this->getFormElementId())
             ->defaultAttribute('name', $name);
 
         $this->addVariables([

+ 1 - 1
src/Form/Field/Slider.php

@@ -25,7 +25,7 @@ class Slider extends Field
     {
         $option = json_encode($this->options);
 
-        $this->script = "setTimeout(function () { $('{$this->elementClassSelector()}').ionRangeSlider($option) }, 400);";
+        $this->script = "setTimeout(function () { $('{$this->getElementClassSelector()}').ionRangeSlider($option) }, 400);";
 
         return parent::render();
     }

+ 3 - 3
src/Form/Field/SwitchField.php

@@ -100,14 +100,14 @@ class SwitchField extends Field
             $this->primary();
         }
 
-        $this->attribute('name', $this->elementName());
+        $this->attribute('name', $this->getElementName());
         $this->attribute('value', 1);
         $this->attribute('type', 'checkbox');
-        $this->attribute('data-plugin', $this->formElementId().'switchery');
+        $this->attribute('data-plugin', $this->getFormElementId().'switchery');
 
         Admin::script(
             <<<JS
-function swty(){\$('[data-plugin="{$this->formElementId()}switchery"]').each(function(){new Switchery($(this)[0],$(this).data())})} swty();
+function swty(){\$('[data-plugin="{$this->getFormElementId()}switchery"]').each(function(){new Switchery($(this)[0],$(this).data())})} swty();
 JS
         );
 

+ 1 - 1
src/Form/Field/Tags.php

@@ -186,7 +186,7 @@ class Tags extends Field
         // 解决部分浏览器开启 tags: true 后无法输入中文的BUG
         // 支持【逗号】【分号】【空格】结尾生成tags
         $this->script = <<<JS
-$("{$this->elementClassSelector()}").select2({
+$("{$this->getElementClassSelector()}").select2({
     tags: true,
     tokenSeparators: [',', ';', ',', ';', ' '],
     createTag: function(params) {

+ 3 - 3
src/Form/Field/Text.php

@@ -21,9 +21,9 @@ class Text extends Field
         $this->prepend('<i class="ti-pencil"></i>')
             ->defaultAttribute('type', 'text')
             ->defaultAttribute('id', $this->id)
-            ->defaultAttribute('name', $this->elementName())
+            ->defaultAttribute('name', $this->getElementName())
             ->defaultAttribute('value', old($this->column, $this->value()))
-            ->defaultAttribute('class', 'form-control '.$this->elementClassString())
+            ->defaultAttribute('class', 'form-control '.$this->getElementClassString())
             ->defaultAttribute('placeholder', $this->placeholder());
 
         $this->addVariables([
@@ -134,7 +134,7 @@ JS
     {
         $options = $this->jsonEncodeOptions($options);
 
-        $this->script = "$('{$this->elementClassSelector()}').inputmask($options);";
+        $this->script = "$('{$this->getElementClassSelector()}').inputmask($options);";
 
         return $this;
     }

+ 1 - 1
src/Form/Field/WebUploader.php

@@ -153,7 +153,7 @@ trait WebUploader
             'fileSizeLimit'       => 20971520000, // 20000M
             'fileSingleSizeLimit' => 10485760, // 10M
             'autoUpdateColumn'    => false, // 上传完图片后自动保存图片路径
-            'elementName'         => $this->elementName(), // 字段name属性值
+            'elementName'         => $this->getElementName(), // 字段name属性值
             'lang'                => trans('admin.uploader'),
 
             'deleteData' => [

+ 3 - 3
src/Form/NestedForm.php

@@ -400,9 +400,9 @@ class NestedForm
             $elementClass = [$this->relationName, $column];
         }
 
-        return $field->errorKey($errorKey)
-            ->elementName($elementName)
-            ->elementClass($elementClass);
+        return $field->setErrorKey($errorKey)
+            ->setElementName($elementName)
+            ->setElementClass($elementClass);
     }
 
     /**

+ 1 - 1
src/Grid/Actions/QuickEdit.php

@@ -27,7 +27,7 @@ class QuickEdit extends RowAction
             $title = trans('admin.edit').' - '.$this->getKey();
 
             Form::modal($title)
-                ->click(".{$this->elementClass()}")
+                ->click(".{$this->getElementClass()}")
                 ->dimensions($width, $height)
                 ->forceRefresh()
                 ->success('LA.reload()');

+ 1 - 1
src/Grid/Displayers/AbstractDisplayer.php

@@ -81,7 +81,7 @@ abstract class AbstractDisplayer
     /**
      * @return string
      */
-    public function elementName()
+    public function getElementName()
     {
         $name = explode('.', $this->column->getName());
 

+ 3 - 3
src/Grid/Displayers/Checkbox.php

@@ -40,7 +40,7 @@ EOT;
         Admin::script($this->script());
 
         return <<<EOT
-<form class="form-group {$this->elementClass()}" style="text-align:left;" data-key="{$this->getKey()}">
+<form class="form-group {$this->getElementClass()}" style="text-align:left;" data-key="{$this->getKey()}">
     $radios
     <button type="submit" class="btn btn-primary btn-xs pull-left">
         <i class="fa fa-save"></i>&nbsp;{$this->trans('save')}
@@ -52,7 +52,7 @@ EOT;
 EOT;
     }
 
-    protected function elementClass()
+    protected function getElementClass()
     {
         return 'grid-checkbox-'.$this->column->getName();
     }
@@ -62,7 +62,7 @@ EOT;
         return <<<JS
 (function () {
     var f;
-    $('form.{$this->elementClass()}').off('submit').on('submit', function () {
+    $('form.{$this->getElementClass()}').off('submit').on('submit', function () {
         var values = $(this).find('input:checkbox:checked').map(function (_, el) {
             return $(el).val();
         }).get(), btn = $(this).find('[type="submit"]');

+ 3 - 3
src/Grid/Displayers/Radio.php

@@ -31,7 +31,7 @@ EOT;
         Admin::script($this->script());
 
         return <<<EOT
-<form class="form-group {$this->elementClass()}" style="text-align: left" data-key="{$this->getKey()}">
+<form class="form-group {$this->getElementClass()}" style="text-align: left" data-key="{$this->getKey()}">
     $radios
     <button type="submit" class="btn btn-primary btn-xs pull-left">
         <i class="fa fa-save"></i>&nbsp;{$this->trans('save')}
@@ -43,7 +43,7 @@ EOT;
 EOT;
     }
 
-    protected function elementClass()
+    protected function getElementClass()
     {
         return 'grid-radio-'.$this->column->getName();
     }
@@ -53,7 +53,7 @@ EOT;
         return <<<JS
 (function () {
     var f;
-    $('form.{$this->elementClass()}').on('submit', function () {
+    $('form.{$this->getElementClass()}').on('submit', function () {
         var value = $(this).find('input:radio:checked').val(), btn = $(this).find('[type="submit"]');
         
         if (f) return;

+ 1 - 1
src/Grid/Displayers/SwitchDisplay.php

@@ -70,7 +70,7 @@ class SwitchDisplay extends AbstractDisplayer
 
         $this->setupScript();
 
-        $name = $this->elementName();
+        $name = $this->getElementName();
         $key = $this->row->{$this->grid->getKeyName()};
         $checked = $this->value ? 'checked' : '';
         $color = $this->color ?: Color::primary();

+ 6 - 6
src/Grid/Filter/Presenter/Select.php

@@ -106,7 +106,7 @@ class Select extends Presenter
             $configs = substr($configs, 1, strlen($configs) - 2);
 
             $this->script = <<<SCRIPT
-$(".{$this->elementClass()}").select2({
+$(".{$this->getElementClass()}").select2({
   placeholder: $placeholder,
   $configs
 });
@@ -193,7 +193,7 @@ SCRIPT;
         $this->script = <<<JS
 
 $.ajax($ajaxOptions).done(function(data) {
-  $(".{$this->elementClass()}").select2({
+  $(".{$this->getElementClass()}").select2({
     data: data,
     $configs
   }).val($values).trigger("change");
@@ -223,7 +223,7 @@ JS;
 
         $this->script = <<<JS
 
-$(".{$this->elementClass()}").select2({
+$(".{$this->getElementClass()}").select2({
   ajax: {
     url: "$resourceUrl",
     dataType: 'json',
@@ -266,7 +266,7 @@ JS;
     {
         return [
             'options'   => $this->buildOptions(),
-            'class'     => $this->elementClass(),
+            'class'     => $this->getElementClass(),
             'selectAll' => $this->selectAll,
         ];
     }
@@ -274,7 +274,7 @@ JS;
     /**
      * @return string
      */
-    protected function elementClass(): string
+    protected function getElementClass(): string
     {
         return $this->elementClass ?:
             ($this->elementClass = $this->getClass($this->filter->column()));
@@ -292,7 +292,7 @@ JS;
      */
     public function load($target, $resourceUrl, $idField = 'id', $textField = 'text'): self
     {
-        $class = $this->elementClass();
+        $class = $this->getElementClass();
 
         $script = <<<JS
 $(document).off('change', ".{$class}");

+ 5 - 5
src/Grid/Tools/QuickCreate.php

@@ -234,11 +234,11 @@ class QuickCreate implements Renderable
      */
     protected function addField(Field $field)
     {
-        $elementClass = array_merge([$this->elementClass()], $field->elementClass());
+        $elementClass = array_merge([$this->getElementClass()], $field->getElementClass());
 
         $field->addElementClass($elementClass);
 
-        $field->view($this->resolveView(get_class($field)));
+        $field->setView($this->resolveView(get_class($field)));
 
         $field::collectAssets();
 
@@ -269,7 +269,7 @@ class QuickCreate implements Renderable
 
         $script = <<<JS
 (function () {
-    var ctr = $('.{$this->elementClass()}'),
+    var ctr = $('.{$this->getElementClass()}'),
         btn = $('.quick-create-button-{$uniqueName}');
     
     btn.click(function () {
@@ -347,7 +347,7 @@ JS;
         Admin::script($script);
     }
 
-    public function elementClass()
+    public function getElementClass()
     {
         $name = $this->parent->getName();
 
@@ -370,7 +370,7 @@ JS;
         $vars = [
             'columnCount'  => $columnCount,
             'fields'       => $this->fields,
-            'elementClass' => $this->elementClass(),
+            'elementClass' => $this->getElementClass(),
         ];
 
         return view('admin::grid.quick-create.form', $vars)->render();