mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-03-07 15:16:40 +08:00
add renderWithOutSubmitButton and disabled apis for OptionForm
This commit is contained in:
parent
ee5fec149e
commit
dcbeb35155
@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
<label for="{{ $id }}">
|
||||
<input {!! $value ? 'checked="true"' : '' !!} type="checkbox" id="{{ $id }}" name="{{ $id }}" value="true"> {{ $label }}
|
||||
<input {!! $value ? 'checked="true"' : '' !!} type="checkbox" id="{{ $id }}" name="{{ $id }}" {{ $disabled or '' }} value="true"> {{ $label }}
|
||||
</label>
|
||||
|
2
resources/views/vendor/option-form/main.tpl
vendored
2
resources/views/vendor/option-form/main.tpl
vendored
@ -32,8 +32,6 @@
|
||||
|
||||
</div><!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
<button type="submit" name="submit" class="btn btn-primary">{{ trans('general.submit') }}</button>
|
||||
|
||||
@foreach($buttons as $button)
|
||||
{!! $button !!}
|
||||
@endforeach
|
||||
|
@ -1,4 +1,4 @@
|
||||
<select class="form-control" name="{{ $id }}">
|
||||
<select class="form-control" name="{{ $id }}" {{ $disabled or '' }}>
|
||||
|
||||
@foreach ((array) $options as $option)
|
||||
<option {!! $selected == $option['value'] ? 'selected="selected"' : '' !!} value="{{ $option['value'] }}">{{ $option['name'] }}</option>
|
||||
|
2
resources/views/vendor/option-form/text.tpl
vendored
2
resources/views/vendor/option-form/text.tpl
vendored
@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="{{ $id }}" value="{{ $value }}">
|
||||
<input type="text" class="form-control" name="{{ $id }}" {{ $disabled or '' }} value="{{ $value }}">
|
||||
|
@ -1 +1 @@
|
||||
<textarea class="form-control" rows="{{ $rows }}" name="{{ $id }}">{{ $value }}</textarea>
|
||||
<textarea class="form-control" rows="{{ $rows }}" name="{{ $id }}" {{ $disabled or '' }}>{{ $value }}</textarea>
|
||||
|
Loading…
Reference in New Issue
Block a user