mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-24 14:04:07 +08:00
Add placeholder method to OptionFormText
This commit is contained in:
parent
64b904107a
commit
53fd30f093
@ -500,12 +500,26 @@ class OptionFormItem
|
|||||||
|
|
||||||
class OptionFormText extends OptionFormItem
|
class OptionFormText extends OptionFormItem
|
||||||
{
|
{
|
||||||
|
protected $placeholder = '';
|
||||||
|
|
||||||
|
public function placeholder($placeholder = OptionForm::AUTO_DETECT)
|
||||||
|
{
|
||||||
|
if ($placeholder == OptionForm::AUTO_DETECT) {
|
||||||
|
$placeholder = trans("options.$this->parentId.$this->id.placeholder");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->placeholder = $placeholder;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('common.option-form.text')->with([
|
return view('common.option-form.text')->with([
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'value' => $this->value,
|
'value' => $this->value,
|
||||||
'disabled' => $this->disabled
|
'disabled' => $this->disabled,
|
||||||
|
'placeholder' => $this->placeholder
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -584,9 +598,13 @@ class OptionFormGroup extends OptionFormItem
|
|||||||
{
|
{
|
||||||
public $items = [];
|
public $items = [];
|
||||||
|
|
||||||
public function text($id, $value = null)
|
public function text($id, $value = null, $placeholder = OptionForm::AUTO_DETECT)
|
||||||
{
|
{
|
||||||
$this->items[] = ['type' => 'text', 'id' => $id, 'value' => $value];
|
if ($placeholder == OptionForm::AUTO_DETECT) {
|
||||||
|
$placeholder = trans("options.$this->parentId.$this->id.placeholder");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->items[] = ['type' => 'text', 'id' => $id, 'value' => $value, 'placeholder' => $placeholder];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -613,7 +631,8 @@ class OptionFormGroup extends OptionFormItem
|
|||||||
|
|
||||||
$rendered[] = view('common.option-form.'.$item['type'])->with([
|
$rendered[] = view('common.option-form.'.$item['type'])->with([
|
||||||
'id' => $item['id'],
|
'id' => $item['id'],
|
||||||
'value' => $item['value']
|
'value' => $item['value'],
|
||||||
|
'placeholder' => array_get($item, 'placeholder')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
<input type="text" class="form-control" name="{{ $id }}" {{ $disabled or '' }} value="{{ $value }}">
|
<input type="text" class="form-control" name="{{ $id }}" {{ $disabled or '' }} value="{{ $value }}" placeholder="{{ $placeholder or '' }}">
|
||||||
|
Loading…
Reference in New Issue
Block a user