Thanks Brian, however if I remove the redirect call it displays the
view for the function "add", i.e. the add.ctp (which doesnt exists),
but I want it to go back to chartofaccounts where the form is, and
then display the errors there.

On Feb 2, 9:30 pm, brian <bally.z...@gmail.com> wrote:
> You don't need to redirect. When you do so, the information stored in
> $validationErrors is lost because you're making a new request. If you
> remove the redirect() call, Cake should simply re-display the form.
> Then if all is working well, FormHelper will take care of printing the
> errors for you.
>
> On Mon, Feb 2, 2009 at 3:23 PM, Mickiii <michael.la...@gmail.com> wrote:
>
> > Hi,
>
> > This is probably simple, but I can't find any specifics on it.
>
> > I have a controller called ledger_controller, which uses two models:
> > Ledgeraccount and Ledgertransaction. Within this controller i have a
> > function called chartofaccounts, which includes a form, with an action
> > that leads to the ledger controller, but a function called "add". I
> > can save the data alright, and also validate it, but I can't get the
> > error messages to show... why is that?
>
> > Controller "ledger":
>
> >        function add () {
> >                if(!empty($this->data)) {
> >                        $this->Ledgeraccount->set($this->data);
> >                        if($this->Ledgeraccount->validates()) {
> >                                $this->Ledgeraccount->save($this->data, 
> > false);
> >                                $this->redirect('chartofaccounts');
> >                        } else {
> >                                $this->Session->setFlash('Venligt ret 
> > fejlene herunder',
> > 'default', array('class'=>'bad'));
> >                                $this->redirect('chartofaccounts');
> >                        }
> >                }
> >        }
>
> > Form in chartofaccounts.ctp
>
> > <?=$form->create('Ledgeraccount', array('url' => '/ledger/add'));?>
>
> > <?
> >        echo $form->input('Ledgeraccount.number');
> >        echo $form->input('Ledgeraccount.name');
> >        echo $form->input('Ledgeraccount.type', array('options' => array(
> >                'header'=>'Header',
> >                'sum'=>'Sum',
> >                'profitloss'=>'Profit Loss',
> >                'balancesheet'=>'Balancesheet'
> >        )));
> > ?>
>
> > <?=$form->end('Create');?>
>
> > If this is standard behaviour, then is there any way I can get the
> > errormessages to show in the chartofaccounts view, without breaking
> > the conventions too much?
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to