优化开关编辑未知状态适配

pull/516/MERGE
Karson 2026-01-14 10:57:09 +08:00
parent be099f6254
commit 92f294d24d
2 changed files with 10 additions and 1 deletions

View File

@ -884,7 +884,7 @@ EOD;
}
$stateNoClass = 'fa-flip-horizontal text-gray';
$formAddElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => $defaultValue, 'fieldSwitchClass' => $defaultValue == $yes ? '' : $stateNoClass]);
$formEditElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => "{\$row.{$field}}", 'fieldSwitchClass' => "{neq name=\"\$row.{$field}\" value=\"{$yes}\"}fa-flip-horizontal text-gray{/neq}"]);
$formEditElement = $this->getReplacedStub('html/' . $inputType . '-edit', ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => "{\$row.{$field}}", 'fieldSwitchClass' => "{neq name=\"\$row.{$field}\" value=\"{$yes}\"}fa-flip-horizontal text-gray{/neq}"]);
} elseif ($inputType == 'citypicker') {
$attrArr['class'] = implode(' ', $cssClassArr);
$attrArr['data-toggle'] = "city-picker";

View File

@ -0,0 +1,9 @@
<input {%attrStr%} name="{%fieldName%}" type="hidden" value="{%fieldValue%}">
<a href="javascript:;" data-toggle="switcher" class="btn-switcher" data-input-id="c-{%field%}" data-yes="{%fieldYes%}" data-no="{%fieldNo%}" >
{if in_array($row.{%field%}, ['{%fieldYes%}', '{%fieldNo%}'])}
<i class="fa fa-toggle-on text-success {neq name="$row.{%field%}" value="{%fieldYes%}"}fa-flip-horizontal text-gray{/neq} fa-2x"></i>
{else/}
<span class="switcher-unknown-val" data-toggle="tooltip" title="{:__('Status unknown, please manually change the status')}"><i class="fa fa-question-circle text-warning"></i></span>
{/if}
</a>