Cakebake generating invalid Controller

Asked

Viewed 49 times

0

I am generating a controller for cakebake based on a table called cliente_planos. It generates controller methods using always $this->ClientePlanos, is generating correctly, but no control method works and found that they only work if I change to $this->Clienteplanos.

The correct is $this->ClientePlanos, but I don’t know where to set up Bake to transform the table cliente_planos in $this->ClientePlanos without giving object error not found.

I’m using cakephp 3 and PHP 5.6.3

  • I’ve been working with cake for 4 years, since I started working with English names has been much better. If you can, do the same, your productivity will increase even more.

1 answer

1

This is a problem caused by the differences between our language and English.

In Cakephp who does this magic of automatically naming is the Inflector library (http://book.cakephp.org/3.0/pt/core-libraries/inflector.html), it has internal rules that work very well for the English language, but you will have this kind of problem when using some terms in English, there are some outputs, are they:

1 - Working Table Naming in English (this is how Cakephp’s conventions work)

2 - manually instantiate the model into the variable you want (e.g.: $Clientplans), and you can even use a property like $this->Clientplans.

3 - create Portuguese language rule set for Inflector and inject into Cake, so you can use conventions without such problems.

A strong hug

  • Dude, there’s no way you can dial my question? I can’t do anything because I don’t have enough reputation, I can’t even mark answers I got right.

Browser other questions tagged

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