'string' ]; /** * @param $value * @return $this */ public function value($value) { if($value === null) return $this; if(!is_array($value)) $this->value[] = (string)$value; else{ foreach ($value as $v){ $this->value[] = (string) $v; } } return $this; } /** * @param null $message * @param string $trigger * @return $this */ public function required($message = null, $trigger = 'change') { $this->setRequired(Helper::getVar($message,'请选择'.$this->title),$trigger,'array'); return $this; } /** * @return array */ public function build() { $options = []; foreach ($this->options as $option){ if ($option instanceof Option) $options[] = $option->build(); } $value = array_unique($this->value); foreach ($value as $k=>$v){ $value[$k] = (string)$v; } return [ 'type'=>$this->name, 'field'=>$this->field, 'title'=>$this->title, 'value'=>$value, 'props'=>(object)$this->props, 'options'=>$options, 'validate'=>$this->validate, 'col'=>$this->col ]; } }