mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-16 22:34:17 +00:00
修改form-builder版本
This commit is contained in:
parent
3559aa9f0f
commit
d2efa0ebda
77
vendor/xaboy/form-builder/src/Form.php
vendored
77
vendor/xaboy/form-builder/src/Form.php
vendored
@ -60,7 +60,6 @@ class Form
|
||||
*/
|
||||
protected $loadCityData = false;
|
||||
|
||||
|
||||
/**
|
||||
* 三级联动 加载省市区数据
|
||||
* @var bool
|
||||
@ -86,7 +85,7 @@ class Form
|
||||
//iview 版本 2.14.3
|
||||
'iview-css' => '<link href="https://cdn.jsdelivr.net/npm/iview@2.14.3/dist/styles/iview.css" rel="stylesheet">',
|
||||
'iview' => '<script src="https://cdn.jsdelivr.net/npm/iview@2.14.3/dist/iview.min.js"></script>',
|
||||
//form-create 版本 1.3.1
|
||||
//form-create 版本 1.3.3
|
||||
'form-create' => '<script src="https://cdn.jsdelivr.net/npm/form-create@1.4.0/dist/form-create.min.js"></script>',
|
||||
'city-data' => '<script src="https://cdn.jsdelivr.net/npm/form-create/district/province_city.js"></script>',
|
||||
'city-area-data' => '<script src="https://cdn.jsdelivr.net/npm/form-create/district/province_city_area.js"></script>'
|
||||
@ -109,6 +108,12 @@ class Form
|
||||
*/
|
||||
protected $action = '';
|
||||
|
||||
/**
|
||||
* 表单id
|
||||
* @var string
|
||||
*/
|
||||
protected $id = '';
|
||||
|
||||
/**
|
||||
* 提交方式
|
||||
* @var string
|
||||
@ -135,12 +140,28 @@ class Form
|
||||
* @param string $action 提交地址
|
||||
* @param array $components 组件
|
||||
*/
|
||||
public function __construct($action, array $components = [])
|
||||
public function __construct($action = '', array $components = [])
|
||||
{
|
||||
$this->components($components);
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoadCityData()
|
||||
{
|
||||
return $this->loadCityData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoadCityAreaData()
|
||||
{
|
||||
return $this->loadCityAreaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $components
|
||||
* @return $this
|
||||
@ -193,6 +214,24 @@ class Form
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
@ -275,6 +314,7 @@ class Form
|
||||
if(!isset($this->components[$field]))
|
||||
$this->fields[] = $field;
|
||||
$this->components[$field] = $component;
|
||||
$this->checkLoadData($component);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -289,9 +329,27 @@ class Form
|
||||
if(!isset($this->components[$field]))
|
||||
array_unshift($this->fields, $field);
|
||||
$this->components[$field] = $component;
|
||||
$this->checkLoadData($component);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormComponentDriver $component
|
||||
*/
|
||||
protected function checkLoadData(FormComponentDriver $component)
|
||||
{
|
||||
if(
|
||||
$component instanceof Cascader
|
||||
&& ($this->loadCityData == false || $this->loadCityAreaData == false)
|
||||
){
|
||||
$type = $component->getType();
|
||||
if ($type == Cascader::TYPE_CITY)
|
||||
$this->loadCityData = true;
|
||||
else if ($type == Cascader::TYPE_CITY_AREA)
|
||||
$this->loadCityAreaData = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得表单规则
|
||||
* @return array
|
||||
@ -303,15 +361,6 @@ class Form
|
||||
$component = $this->components[$field];
|
||||
if (!($component instanceof FormComponentDriver))
|
||||
continue;
|
||||
|
||||
$loadData = $this->loadCityData == true && $this->loadCityAreaData == true;
|
||||
if ($loadData == false && $component instanceof Cascader) {
|
||||
$type = $component->getType();
|
||||
if ($type == Cascader::TYPE_CITY)
|
||||
$this->loadCityData = true;
|
||||
else if ($type == Cascader::TYPE_CITY_AREA)
|
||||
$this->loadCityAreaData = true;
|
||||
}
|
||||
$rules[] = $component->build();
|
||||
}
|
||||
return $rules;
|
||||
@ -326,7 +375,6 @@ class Form
|
||||
{
|
||||
ob_start();
|
||||
$form = $this;
|
||||
$rule = $this->getRules();
|
||||
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'form.php';
|
||||
$html = ob_get_clean();
|
||||
return $html;
|
||||
@ -349,7 +397,6 @@ class Form
|
||||
{
|
||||
ob_start();
|
||||
$form = $this;
|
||||
$rule = $this->getRules();
|
||||
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'formScript.php';
|
||||
$script = ob_get_clean();
|
||||
return $script;
|
||||
@ -379,7 +426,7 @@ class Form
|
||||
|
||||
/**
|
||||
* 生成表单快捷方法
|
||||
* @param $action
|
||||
* @param string $action
|
||||
* @param array $components
|
||||
* @return Form
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user