0

I am working in cakephp 2.x

my current url is http://sitename.com/users/edit_profile#step-2 when i submit page i am not getting #setp-2

Code:

//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());
        }
    }
}

How to getting hashtag in cakephp form submit?

Developer
  • 2,676
  • 8
  • 43
  • 65

2 Answers2

0

Use

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

It appends #step-2 as you need in the url, similarly you can use your for ? also

Abhishek
  • 795
  • 9
  • 20
0

The hash is never sent to the server.

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

though you can set a hidden field and set the value = .

you can access the hash by document.location.hash

Sougata Bose
  • 31,517
  • 8
  • 49
  • 87