7
This commit is contained in:
Regular → Executable
+6
-3
@@ -6,7 +6,7 @@ class Html extends \think\template\TagLib{
|
||||
* 定义标签列表
|
||||
*/
|
||||
protected $tags = [
|
||||
'switch' => ['attr' => 'name,yes,no,value', 'close' => 0],
|
||||
'switch' => ['attr' => 'name,yes,no,value,title', 'close' => 0],
|
||||
'radio' => ['attr' => 'name,options,value', 'close' => 0],
|
||||
'checkbox' => ['attr' => 'name,options,value', 'close' => 0],
|
||||
'upload' => ['attr' => 'name,value,mimetype,multiple,url,maxsize,maxcount,params', 'close' => 0]
|
||||
@@ -74,6 +74,7 @@ class Html extends \think\template\TagLib{
|
||||
{
|
||||
$yes = isset($tag['yes'])?$tag['yes']:1;unset($tag['yes']);
|
||||
$no = isset($tag['no'])?$tag['no']:0;unset($tag['no']);
|
||||
$title_text = isset($tag['title'])?$tag['title']:"开|关";unset($tag['title']);
|
||||
$value = isset($tag['value'])?$tag['value']:1;unset($tag['value']);
|
||||
$name = isset($tag['name'])?$tag['name']:'';unset($tag['name']);
|
||||
// 支持用函数传数组
|
||||
@@ -82,15 +83,17 @@ class Html extends \think\template\TagLib{
|
||||
$value = $this->buildvar($value,$parseStr,'value');
|
||||
$no = $this->buildvar($no,$parseStr,'no',0);
|
||||
$yes = $this->buildvar($yes,$parseStr,'yes',1);
|
||||
$title_text = $this->buildvar($title_text,$parseStr,'title_text','');
|
||||
$extendData = $this->buildExtendData($tag);
|
||||
$parseStr .= '<?php ';
|
||||
$parseStr .= $yes.'='.$yes.'??1;'.PHP_EOL;
|
||||
$parseStr .= $no.'='.$no.'??0;'.PHP_EOL;
|
||||
$parseStr .= $value.'='.$yes.'=='.$value .' ? '.$yes.' : '.$no.';'.PHP_EOL;
|
||||
$parseStr .= '?><label data-role="switcher" class="lyear-switch switch-success switch-light switch-outline">';
|
||||
$parseStr .= $title_text.'=explode("|",'.$title_text.');'.PHP_EOL;
|
||||
$parseStr .= '?><label data-role="switcher" class="lyear-switch switch-success switch-light">';
|
||||
$parseStr .= ' <input type="hidden" data-yes="{'.$yes.'}" data-no="{'.$no.'}" id="c-{'.$name.'}" name="{'.$name.'}" value="{'.$value.'}"/>';
|
||||
$parseStr .= ' <input id="c-{'.$name.'}-switch" type="checkbox" {if '.$yes .'=='. $value.'}checked{/if} '.$extendData.' />';
|
||||
$parseStr .= ' <span></span>';
|
||||
$parseStr .= ' <i data-on-text="{'.$title_text.'[0]}" data-off-text="{'.$title_text.'[1]}"></i>';
|
||||
$parseStr .= '</label>';
|
||||
return $parseStr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user