2014-09-03 50 views
0

我在CakePHP的2.x的工作如何在CakePHP表單中獲取HashTag提交?

我目前的網址是http://sitename.com/users/edit_profile#step-2當我提交我沒有得到頁面#setp-2

代碼:

//Setp-2 
<?php echo $this->form->create('User',array('action'=>'edit_profile')); ?> 
    <label>Smoke</label> 
    <?php $smoke_option = array('Heavy'=>'Heavy','Moderate'=>'Moderate','Light'=>'Light','Occasional'=>'Occasional','Non Smoker'=>'Non Smoker','Herb'=>'Herb'); 
    echo $this->form->input('smoke', array('options' => $smoke_option,'default'=>$getProfile['User_detail']['smoke'],'label'=>false,'div'=>false,'empty'=>'No Answer'));?> 
    </div> 
<?php echo $this->form->end();?> 

UsersController.php

public function edit_profile(){ 
    $this->layout='default';   
    if($this->request->is('post')){ 
     $data = $this->request->data; 
     $data['User']['id']=$this->Session->read('Auth.User.id'); 
     $updateProfile=$this->User->add_details($data); 
     if($updateProfile){ 
      $this->Session->setFlash(__('Your Profile Updated Successfully'), 'success_message'); 
      $this->redirect($this->referer()); 
     } 
    } 
} 

如何獲取cakephp表單中的hashtag提交?

回答

0

使用

array('action'=>'edit_profile', '#' => 'step-2') 

其追加#步驟2中,你在url需要,同樣你可以用你的呢?還有

0

散列永遠不會發送到服務器。

裁判 - http://stackoverflow.com/questions/940905/can-php-read-the-hash-portion-of-the-url

雖然你可以設置一個隱藏字段並設置值=。

您可以通過document.location.hash