diff --git a/app/Services/OptionForm.php b/app/Services/OptionForm.php index c3d7fd33..824ad96b 100644 --- a/app/Services/OptionForm.php +++ b/app/Services/OptionForm.php @@ -26,6 +26,7 @@ class OptionForm protected $renderWithOutTable = false; protected $renderInputTagsOnly = false; + protected $renderWithOutSubmitButton = false; /** * Create a new option form instance. @@ -301,6 +302,13 @@ class OptionForm return $this; } + public function renderWithOutSubmitButton() + { + $this->renderWithOutSubmitButton = true; + + return $this; + } + /** * Get the string contents of the option form. * @@ -312,6 +320,16 @@ class OptionForm call_user_func($this->alwaysCallback, $this); } + // attach submit button to the form + if (!$this->renderWithOutSubmitButton) { + $this->addButton([ + 'style' => 'primary', + 'text' => trans('general.submit'), + 'type' => 'submit', + 'name' => 'submit' + ]); + } + $this->assignValues(); return view('vendor.option-form.main')->with(array_merge(get_object_vars($this)))->render(); @@ -338,6 +356,8 @@ class OptionFormItem public $value = null; + public $disabled; + public $description; public function __construct($id, $name = null) @@ -360,6 +380,13 @@ class OptionFormItem return $this; } + public function disabled($disabled = "disabled") + { + $this->disabled = "disabled=\"$disabled\""; + + return $this; + } + public function description($description) { $this->description = $description; @@ -384,8 +411,9 @@ class OptionFormText extends OptionFormItem public function render() { return view('vendor.option-form.text')->with([ - 'id' => $this->id, - 'value' => $this->value + 'id' => $this->id, + 'value' => $this->value, + 'disabled' => $this->disabled ]); } } @@ -406,7 +434,8 @@ class OptionFormCheckbox extends OptionFormItem return view('vendor.option-form.checkbox')->with([ 'id' => $this->id, 'value' => $this->value, - 'label' => $this->label + 'label' => $this->label, + 'disabled' => $this->disabled ]); } } @@ -427,7 +456,8 @@ class OptionFormTextarea extends OptionFormItem return view('vendor.option-form.textarea')->with([ 'id' => $this->id, 'rows' => $this->rows, - 'value' => $this->value + 'value' => $this->value, + 'disabled' => $this->disabled ]); } } @@ -448,7 +478,8 @@ class OptionFormSelect extends OptionFormItem return view('vendor.option-form.select')->with([ 'id' => $this->id, 'options' => $this->options, - 'selected' => $this->value + 'selected' => $this->value, + 'disabled' => $this->disabled ]); } } diff --git a/resources/views/vendor/option-form/checkbox.tpl b/resources/views/vendor/option-form/checkbox.tpl index ba91f33d..3a02825e 100644 --- a/resources/views/vendor/option-form/checkbox.tpl +++ b/resources/views/vendor/option-form/checkbox.tpl @@ -1,3 +1,3 @@ diff --git a/resources/views/vendor/option-form/main.tpl b/resources/views/vendor/option-form/main.tpl index 98bf181b..db6ca41c 100644 --- a/resources/views/vendor/option-form/main.tpl +++ b/resources/views/vendor/option-form/main.tpl @@ -32,8 +32,6 @@