自定义表单功能(X)
This commit is contained in:
@@ -35,10 +35,20 @@ class Form extends Admin {
|
||||
/**
|
||||
* 添加表单
|
||||
*/
|
||||
public function add(){
|
||||
public function add(\think\Request $request){
|
||||
if (IS_POST) {
|
||||
# code...
|
||||
$result = $this->model->validate('Form')->save($request->post());
|
||||
if (false !== $result) {
|
||||
return $this->success('添加成功!', url('admin/form/index'));
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$data = array(
|
||||
'keyList' => $this->model->addField
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('添加表单');
|
||||
return $this->fetch('public/edit');
|
||||
}
|
||||
}
|
||||
@@ -46,10 +56,22 @@ class Form extends Admin {
|
||||
/**
|
||||
* 编辑表单
|
||||
*/
|
||||
public function edit(){
|
||||
public function edit(\think\Request $request){
|
||||
if (IS_POST) {
|
||||
# code...
|
||||
$result = $this->model->validate('Form')->save($request->post(), array('id'=> $request->post('id')));
|
||||
if (false !== $result) {
|
||||
return $this->success('修改成功!', url('admin/form/index'));
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$info = $this->model->where('id', $request->param('id'))->find();
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $this->model->editField
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('编辑表单');
|
||||
return $this->fetch('public/edit');
|
||||
}
|
||||
}
|
||||
@@ -77,4 +99,6 @@ class Form extends Admin {
|
||||
public function lists(){
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function attr(){}
|
||||
}
|
||||
@@ -27,8 +27,42 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{notempty name="list"}
|
||||
{volist name="list" id="item"}
|
||||
<tr>
|
||||
<td>
|
||||
<input class="ids" type="checkbox" name="ids[]" value="{$item['id']}" />
|
||||
</td>
|
||||
<td>{$item['id']}</td>
|
||||
<td>{$item['name']}</td>
|
||||
<td>
|
||||
<a data-id="{$item.id}" href="{:url('model/edit?id='.$item['id'])}">{$item['title']}</a>
|
||||
</td>
|
||||
<td>
|
||||
<span>{$item.create_time|time_format}</span>
|
||||
</td>
|
||||
<td>
|
||||
{if $item['status']}
|
||||
<span class="label label-primary">{$item['status_text']}</span>
|
||||
{else/}
|
||||
<span class="label label-danger">{$item['status_text']}</span>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{:url('admin/form/attr?form_id='.$item['id'])}">字段</a>
|
||||
<a href="{:url('admin/form/status?id='.$item['id'].'&status='.abs(1-$item['status']))}" class="ajax-get">{$item['status']|show_status_op}</a>
|
||||
<a href="{:url('admin/form/edit?id='.$item['id'])}">编辑</a>
|
||||
<a href="{:url('admin/form/del?id='.$item['id'])}" class="confirm ajax-get">删除</a>
|
||||
<a href="{:url('admin/form/lists?form_id='.$item['id'])}">数据</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
{else/}
|
||||
<td colspan="7" class="text-center">aOh! 暂时还没有创建模型!</td>
|
||||
{/notempty}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user