listen = $listen; return $this; } public function render() { $this->addVariables(['listen' => $this->listen]); return parent::render(); } /** * 格式化保存值 * * @param [type] $data * @return void */ protected function prepareInputValue($value) { $specs = $value; if ($specs) { $specs = json_decode($specs, true); foreach ($specs as $key=> &$item) { $item['items'] = array_filter(array_map(function ($value) { if ($value['value'] !=='' && $value['name'] !== 'NONE') { return $value; } }, $item['specs'])); unset($item['specs']); //如果该组无值,则删除该组 if (count($item['items']) < 1) { unset($specs[$key]); } } } return $specs; } /** * 格式化渲染值 * * @param [type] $value * @return void */ protected function formatFieldData($data) { $value = parent::formatFieldData($data); return $value; } }