Do you have a FinanceiroCategorium model? If not, it looks like a
problem with Cake's pluralisation rules, though It's not quite clear
to me why it would do that. Basically, models are named in the
singular, and controllers use the plural version of the model name. In
English, it would be (model) FinancialCategory and
FinancialCategoriesController. So Cake would be expecting a controller
named FinanceiroCategoriumController. But why it would use the "ium"
for the model is confusing.
Anyway, try adding this line (and leaving the controller name as is):
class FinanceiroCategoriaController extends AppController {
public $uses = array('FinanceiroCategoria');
On Tue, Oct 9, 2012 at 2:44 PM, Newton Pasqualini
<[email protected]> wrote:
> Hi folks,
>
> I need help here with a strange problem.
>
> I am a newbie in CakePHP sorry if this is some stupid mistake.
>
> So, my envirorment MySQL 5.1, PHP 5.3, CakePHP 2.2
>
> Model/FinanceiroCategoria.php
> <?php
> class FinanceiroCategoria extends AppModel {
> public $useTable = 'financeiro_categoria';
> public $name = 'FinanceiroCategoria';
> public $validate = array(
> 'nome' => array(
> 'required' => array(
> 'rule' => array('notEmpty'),
> 'message' => 'Digite um nome para a Categoria.',
> )
> ),
> );
> public $paginate = array(
> 'fields' => array('FinanceiroCategoria.id',
> 'FinanceiroCategoria.nome'),
> 'paramType' => 'querystring',
> 'limit' => 25,
> 'order' => array(
> 'FinanceiroCategoria.id' => 'desc'
> )
> );
> }
>
> Controller/FinanceiroCategoriaController.php
> <?php
> class FinanceiroCategoriaController extends AppController {
> public function index() {
> $this->set('categorias', $this->paginate());
> }
>
> public function view($id = null) {
> $this->FinanceiroCategoria->id = $id;
> if (!$this->FinanceiroCategoria->exists()) {
> throw new NotFoundException(__('Categoria Inválida'));
> }
> $this->set('categoria', $this->FinanceiroCategoria->read(null,
> $id));
> }
>
> public function add() {
> if ($this->request->is('post')) {
> $this->FinanceiroCategoria->create();
> if ($this->FinanceiroCategoria->save($this->request->data)) {
> $this->Session->setFlash(__('Categoria Salva!'));
> $this->redirect(array('action' => 'index'));
> } else {
> $this->Session->setFlash(__('Não foi possível processar sua
> solicitação, tente mais tarde.'));
> }
> }
> }
>
> public function edit($id = null) {
> $this->FinanceiroCategoria->id = $id;
> if (!$this->FinanceiroCategoria->exists()) {
> throw new NotFoundException(__('Categoria inválida!'));
> }
> if ($this->request->is('post') || $this->request->is('put')) {
> if ($this->FinanceiroCategoria->save($this->request->data)) {
> $this->Session->setFlash(__('Categoria Salvo!'));
> $this->redirect(array('action' => 'index'));
> } else {
> $this->Session->setFlash(__('Verifique os erros abaixo e
> tente novamente.'));
> }
> } else {
> $this->request->data = $this->FinanceiroCategoria->read(null,
> $id);
> unset($this->request->data['FinanceiroCategoria']['senha']);
> }
> }
>
> public function delete($id = null) {
> if ($this->request->is('post')) {
> throw new MethodNotAllowedException();
> }
> $this->FinanceiroCategoria->id = $id;
> if (!$this->FinanceiroCategoria->exists()) {
> throw new NotFoundException(__('Categoria inválida!'));
> }
> if ($this->FinanceiroCategoria->delete()) {
> $this->Session->setFlash(__('Categoria Removida!'));
> $this->redirect(array('action' => 'index'));
> }
> $this->Session->setFlash(__('A categoria não foi removida!'));
> $this->redirect(array('action' => 'index'));
> }
> }
>
> So, I think the controller is not properly bridged to the respective model,
> why? Because my Validation in model is not visible in the form, and in the
> index action the view load in $categorias the Pagination for the model
> "FinanceiroCategorium" and not "FinanceiroCategoria".
>
> The question, is there a way to tell for the controller use
> "FinanceiroCategoria" model?
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.