if you do it my way - the error message from the validate array will be put under the dropdown on the same page. in the action there would be something similar to bake generates but with $this->Model->validates() iinstead of save() if it valdiates - show the other view with the table
you can come to the irc channel #cakephp for some help On Thu, May 1, 2008 at 11:00 AM, annie.r.knight <[EMAIL PROTECTED]> wrote: > > Thanks for the quick reply. > > I'm not sure whether that solves my problem: I'm okay with selecting > which output to produce, my problem is in the construction of the > books table/warning message. Where does this occur? > > What I've got at the moment is something like this in the view: > > if(!$showtable) { > // display the warning message > } > else { > // show the books table > } > > The alternative, as I see it, would be to set the variable > $tableoutput in the controller to contain either the message or the > table and simply to echo that in the view. > > With the first example I'm including logic in the view, with the > second I'm including presentation in the controller. I assume that, > since this isn't business logic, the first method is the correct one. > > Is there a better way? I imagine so. > > > > On May 1, 9:46 am, "Marcin Domanski" <[EMAIL PROTECTED]> wrote: > > Hey, > > From what you said you want to make a validation rule like >0 (if 0 is > > the value of ---please select a genre---) and Model::validate() it > > (you probably dont want to save it), if it valdiates - show the books > > > > On Thu, May 1, 2008 at 9:54 AM, annie.r.knight > > > > > > > > > <[EMAIL PROTECTED]> wrote: > > > > > ... at least I hope it's simple for you guys. Clearly it's not simple > > > for me otherwise I wouldn't be asking here. I'm using 1.2. > > > > > I'm trying to get the structure of my app 'right' in terms of MVC > > > execution flow (and CakePHP's implementation of this flow). Here's my > > > situation: > > > > > I've got a page where a drop-down menu offers a number of options > > > relating to, say, the genre of books available in a small library. The > > > user chooses the genre from this drop-down and is then presented with > > > a table data relating to the individual books in that genre. > > > > > All easy-peasy coding. In the past (pre-MVC) I would simply have > > > included some logic in the page to say: if there is no genre selected, > > > then output a message telling user to select one; if there is then > > > output the books in a nice table. This would, as I understand it, by > > > an incorrect in terms of MVC. > > > > > So here's my quandry. > > > > > Do I 'set' the entire text of the table/user message in the > > > controller, then output it as a simple $variable in the view? The > > > disadvantage of this view would be that I need to include > > > presentational logic when making the table/message within the > > > controller. > > > > > I've got a feeling there's a cleaner solution! Please advise! > > > > -- > > Marcin Domanskihttp://kabturek.info > > > > > -- Marcin Domanski http://kabturek.info --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---