How to create function for view?

Asked

Viewed 143 times

0

I’m creating a role in controller UsersController, this function is for users who forget the password. When I try to open the view, returns an error that the function does not exist.

The structure is like this:

  • view esqueci_senha.ctp
  • function function esqueciSenha()

To open the view I do so:

<a href="<?php echo $this->Html->url("/Users/esqueci_senha")?>"><i class="glyphicon glyphicon-question-sign"></i> Esqueci minha senha</a>`

The mistake:

Error: The action forgetting password is not defined in controller Userscontroller

Error: Create Userscontroller::forgetful_password() in file: app Controller Userscontroller.php.

class Userscontroller extends Appcontroller {

public Function forgetting password() {

}

}

How to solve?

2 answers

1

The mistake says he’s hoping that the action, in his controller, calling esqueci_senha, and not esqueciSenha. I guess just fix it in the controller:

function esqueci_senha() {
    // código da action
}
  • i had already done this, I changed the name of the function as you are suggesting and tbm the name of the view, but when I click on the link to open simply does not open, reload the page and does not open.

  • And with the URL /Users/esqueciSenha?

  • Woe gives the following error: Error: The view for UsersController::esqueciSenha() was not found.

  • I managed to solve, the function has to be called esqueciSenha and the view esqueci_senha, I did that and it worked. Thank you.

  • But that’s what you said you had and it didn’t work!

  • 1

    no, look at the post that in the url I invoked the view esqueci_senha and now I switched to invoke the function esqueciSenha, I think by default the cake uses the underline for the view when the function eh camelcase.

Show 1 more comment

0

Na Controller:

Class UsersController extends AppController {

    public function esqueciSenha() {

    }

}

File name: forget_password.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.