Thank you for the feedback. The beforeSave() trick could be one possibilty, but in this particular case it seems that the defaultPhotoId suggested by Goranche is the easiest.
On 18 ene, 15:27, Jaime <[EMAIL PROTECTED]> wrote: > Hello bakers! > > Imagine this (common) scenario: a photo album that HasMany photos. A > user may select one of them as a "cover" or "default" photo to > illustrate the cover of the album. So a boolean field called "default" > is set in the Photo model. Of course one and only one photo within > that album should have the "default" bit set, because it's non-sense > to flag more than one for the same album. > > This leads to some extra logic within the controller in order to unset > all other possibly previously flagged photos before setting the new > one. This is not a big deal nor very important, but is not very > beautiful either, is it? > > As the great piece of software CakePHP is, perhaps there is the > possibility to specify within the model that only one register within > a given set can have a boolean field set. Or maybe can be defined > somehow in the MySQL DB. > > I hope this is not a too philosophical question :-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
