在localhost上查看同一页面时出错

时间:2016-08-04 04:47:28

标签: php cakephp

我的ctp文件代码:

<?php echo $this->Form->create('Users',array('action'=>'port_settings_edit')); ?>

<tr><td><center><?php echo $this->Form->input('process',array('type'=>'hidden','value'=>$pid,'id'=>'pid')); ?>
<?php echo $pname; ?></center></td><td><center>
<?php echo $characteristic; ?></center></td><td><center>
<select id="deviceid"></select></center></td><td><center><select id="instid">
<option value="">Select Any</option>
<option value="xyzz">xyzz</option>
<option value="fgh">fgh</option>
<option value="abc">abc</option>
</select></center></tr></table>
<BR><BR> &nbsp; &nbsp; &nbsp;
<button type="submit" id="submit_btn" class="bott1"><font size=3 ><b>SUBMIT</b></font></button>
  • 在我的控制器中定义的功能:

    function port_settings_edit($id=null)        
    {
        $this->loadModel('Process');
        $op=$this->Process->find('first',array('conditions'=>array('Process.id'=>$id)));
    
         $this->set('pname',$op['Process']['name']);//ERROR
         $this->set('pid',$op['Process']['id']);//ERROR
         $this->set('characteristic',$op['Process']['characteristic']);//ERROR
         if(!empty($this->data))
         { 
           //$this->layout = false; 
           //print_r($this->data);
           $this->Session->setFlash('PORTS SETTINGS ARE DONE SUCCESSFULLY.');
           $this->redirect(array('action'=>'viewport'));              
         }
    }
    

我在这3行遇到同样的错误。即

  

未定义语法:进程

我已经定义了变量。

1 个答案:

答案 0 :(得分:0)

我可以在CakePHP代码中看到一些问题。

  1. 在您已通过 $ id 的方法中,表单操作网址也是错误的应该是<?php echo $this->Form->create('Users',array('url'=>['action'=>'port_settings_edit',$pid]));?>
  2. 也不需要在隐藏字段中传递$ pid,因为你是从网址获取的。
  3. 另请注意您正面临的错误。

相关问题