想把传统的type="text"实现type="textarea"的效果,比如下设置为type="textarea"显然不生效:
<input value="{$xinxianshi['mingcheng']}" type="text" name="mingcheng" placeholder="实例格式:1999-10-14" id="inputbirthday" >
可以用以下方法实现:
view
<form action="{:U('Xinxianshi/bianji')}" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?=$xinxianshi['id']?>">
<div class="box-header">
<h3 class="box-title"></h3>
<a href="{:U('list')}" class="btn btn-default pull-right">新鲜事列表</a>
</div><!-- /.box-header -->
<div class="box-body">
<!-- s -->
<tr><TD align="right" width=120 height=60>留言内容</TD><td></td></tr>
<!-- d -->
<div class="form-group">
<label for="inputSubject"></label>
<input value="{$xinxianshi['neirong']}" type="hidden" name="neirong" id="inputidnumber" placeholder="max<20位" maxlength="20" /><textarea value="{$xinxianshi['neirong']}" name="neirong" style=" height:100%;"
>{$xinxianshi['neirong']}</textarea><br />
</div>
<div class="form-group">
<label for="inputSubject">是否显示</label>
<tr >
<td> <input type="radio" name="xianshi" id="inputSubject" value="1" >是
</td>
<td> <input type="radio" name="xianshi" id="inputSubject" value="0"></td>否
</tr>
<!-- <input type="radio" name="RR" value="1">
<input type="radio" name="RR" value="2"> -->
</div>
</div><!-- /.box-body -->
<div class="box-footer clearfix">
<!-- <a href="{:U('edit', ['user_id'=>$user['id']])}" class="btn btn-default" title="编辑"><span class="fa fa-edit"></span> 编辑</a> -->
<button class="btn btn-primary" type="submit" name="submit" value="publish">更新</button>
<!-- <button class="btn btn-info" type="submit" name="submit" value="save">仅保存</button> -->
</div><!-- /.box-footer -->
</form>
controller:
//start
/**
* 编辑前展示xinxianshi
*/
public function bianjiAction($xinxianshi_id=0)
{ //s
//e
// 通用查询条件
$m_xinxianshi = M('Xinxianshi');
//匹配xinxianshiid并展示:
$condition['id'] = $xinxianshi_id;
$m_xinxianshi = D('Xinxianshi');
$xinxianshi = $m_xinxianshi
->table('lb_xinxianshi')
->field('lb_xinxianshi.*')
->where($condition)
->find();
$this->assign('xinxianshi', $xinxianshi);
//echo $m_xinxianshi->getLastSQL();exit;
//var_dump($xinxianshi);
//$this->display();
//更新
// 判断当前是post还是get
if (IS_POST)
{
$m_xinxianshi = D('Xinxianshi');
// 处理提交的数据
$m_xinxianshi->create(); // 默认去post中获取数据
$m_xinxianshi->birthday = strtotime($_POST['birthday']);
$m_xinxianshi->regtime = time();
$m_xinxianshi->logintimes = time();
// 数据校验通过
$m_xinxianshi->save();
// 数据插入或者验证无存在问题
$this->success('OK:' , U('Xinxianshi/list'), 2);
}
else
{
// 展示添加表单
// 把分类分配给表单
$m_category = D('Category');
$category_list = $m_category->getTree();
$this->assign('category_list', $category_list);
$this->display();
}
}
//end
效果: