在聪明的模板里面的帮手代码点火器

时间:2011-10-10 03:05:40

标签: php codeigniter smarty

如果我将带有数组参数的form_helper放入我的智能模板中,这是否可行。

这是我控制器的方法:

function input($pIntBookId = 0) {
   $this->load->model('m_books');
   if($this->input->post('mysubmit')){
       if($this->input->post('id')){

           $this->m_books->entryUpdate();

       }else{
           $this->m_books->entryInsert();
       }
   }
   $arrData = $this->m_books->general();
   if((int)$pIntBookId>0){
       $strQuery = $this->m_books->getId($pIntBookId);
       $arrData['idxFid']['value'] = $strQuery['book_id'];
       $arrData['idxFtitle']['value'] = $strQuery['book_nm'];
       $arrData['idxFauthor']['value'] = $strQuery['book_aut'];
       $arrData['idxFpublisher']['value'] = $strQuery['book_pub'];
       $arrData['idxFyear']['value'] = $strQuery['book_year'];
       if($strQuery['book_st']=='yes'){
           $arrData['idxFavailable']['checked'] = true;
       }else{
           $arrData['idxFavailable']['checked'] = false;
       }
       $arrData['idxFsummary']['value'] = $strQuery['book_ds'];
   }
   $this->mysmarty->assign('arrData',$arrData);
   $this->mysmarty->view('v_booksinput.php');
}

这可能吗?? :

<td>{php} echo form_input($idxFtitle);{/php}</td>

1 个答案:

答案 0 :(得分:0)

你可以自己写smarty-function来做你想做的事。

{function name="my_input" data}
<input name="{data['value']}"></input>
{/function}