SluggedTree behavior destroys data $Model->data field
Hi, I have a model Page which looks like this: http://pastebin.com/m7fa0d789 and SQL table that looks like this: http://pastebin.com/m55d36fb3 I'm using SluggedTree behavior in Page model to generate slugs and slug paths of every page. I have a form to edit contents of a single page. After submitting a form I observed that when using this behavior Page::data array doesn't contain all of fields POST'ed from the form. To be exact - data field looks normal in Model::beforeSave(), but not in Model::afterSave() method. In the afterSave method Model::data array contains only path field and slug field from SluggedTreeBehavior, the rest of the POSTed data is gone! Anyone familiar with this problem? What would You recommend to generate slugs and slug-paths? Slug-paths are a must-have for me, because I have to create links like http://server.com/products/productA/features, and can't use IDs in URLs and having a slug-path makes easy to find a proper page: Router::connect(/:path, null, array('path' => '[\w/]+')); and in the controller $page = $Page->findBySlugPath($path)); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: hasMany join table that stores the actual ForeignKey
and actually, I don't think this meets my requirement. since i need to be able to do users<>users_addresses<>addresses and the table users_addresses is just a hasMany relationship to addresses. because these addresses are not types, they are assigned to corporations, billing, properties, clients, etc. On Feb 5, 5:17 pm, Robert K wrote: > could you possibly show me exactly how the model would look / table > structure ? > examples speak louder than words for me. > > On Feb 5, 11:58 am, John Andersen wrote: > > > Would it not be simpler to have the following tables and associations/ > > relationships: > > > Tables: users, addresses, addresstypes > > > Models: User, Address, Addresstype > > > With associations/relationships: > > User hasMany/belongsTo Address > > Address belongsTo/hasMany Addresstype > > > Where addresstypes identifies whether an address is a private address > > or a company address (and others if necessary). > > > Thus in a form, the user enters the address, and chooses the > > addresstype, saves, and all is well :) > > > Would the above satisfy your requirements? > > Enjoy, > > John > > > On Feb 5, 9:26 pm, Robert K wrote: > > > > user needs to store addresses. > > > Address table can store addresses for any type of relationship, users, > > > companies, etc. > > > > user_addresses, > > > company_addresses, ... > > > > addresses table (id,address1,address2,city,zip,...) > > > > user_addresses (id,user_id,address_id) > > > company_addresses (id,company_id,address_id) > > > > so when creating a user, what will happen is not only will cake create > > > the relationship bonding in the _addresses table, but also > > > creating the address record in the addresses table. > > > > I could not figure out a legitimate way in cakePHP to do this with the > > > saveAll function. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: hasMany join table that stores the actual ForeignKey
could you possibly show me exactly how the model would look / table structure ? examples speak louder than words for me. On Feb 5, 11:58 am, John Andersen wrote: > Would it not be simpler to have the following tables and associations/ > relationships: > > Tables: users, addresses, addresstypes > > Models: User, Address, Addresstype > > With associations/relationships: > User hasMany/belongsTo Address > Address belongsTo/hasMany Addresstype > > Where addresstypes identifies whether an address is a private address > or a company address (and others if necessary). > > Thus in a form, the user enters the address, and chooses the > addresstype, saves, and all is well :) > > Would the above satisfy your requirements? > Enjoy, > John > > On Feb 5, 9:26 pm, Robert K wrote: > > > user needs to store addresses. > > Address table can store addresses for any type of relationship, users, > > companies, etc. > > > user_addresses, > > company_addresses, ... > > > addresses table (id,address1,address2,city,zip,...) > > > user_addresses (id,user_id,address_id) > > company_addresses (id,company_id,address_id) > > > so when creating a user, what will happen is not only will cake create > > the relationship bonding in the _addresses table, but also > > creating the address record in the addresses table. > > > I could not figure out a legitimate way in cakePHP to do this with the > > saveAll function. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: friends and self HABTM
No, CakePHP uses your HABTM definition between User and Friend (User), so that it knows, that your User.id and your Friend.id must go into the users_users table. John On Feb 5, 10:23 pm, Foroct wrote: > John, > > Wouldn't that save my data to my users table and not my users_users > table? The users_users table is where the friendships are kept. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Create association with a join table.
Hi, having some problems understanding how to create an association between two existing records. The scenario is the following. I have recipes and menus. When viewing a recipe I want the user to be able to select a menu from a list to add the recipe to. (Menus contain Recipes). So once again, the recipe and the list of menus already exist. When I submit the data to the Menu->save() method it complains that I am missing fields. This would make sense if I was creating a new menu and associating recipes at the same time, but I am not. All that needs to happen is to insert a new record into menus_recipes (join table) that has the recipe_id and menu_id. In concept this is simple but something about model associations is eluding me. This is the top of the recipe view file where I create a form to send the menu_id and the recipe_id: Recipe Recipe create('Menu', array('url'=>'/menus/add_recipe')); echo $form->input('Recipe.recipe_id', array('value'=> $recipe['Recipe']['id'], 'label'=>false, 'type'=>'hidden')); echo $form->input('Menu.menu_id'); $form->end('Add to Menu'); ?> Here is menus_controller add_recipe: public function add_recipe() { var_dump($this->data); $this->Menu->saveAll($this->data); $this->Session->setFlash('The recipe has been added to the menu'); $this->redirect(array('controller'=>'recipes', 'action'=>'index')); } I am probably going to just write a raw SQL statement to take care of this but I would really like to know the correct Cake methodology for this. I honestly have read the docs and cant find what I am looking for, which probably means I am looking for the wrong thing. If you are really interested here is a link to the source code in Google's project hosting: http://code.google.com/p/menurecipemanager/ Thanks for any help or advice. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: friends and self HABTM
John, Wouldn't that save my data to my users table and not my users_users table? The users_users table is where the friendships are kept. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: hasMany join table that stores the actual ForeignKey
Would it not be simpler to have the following tables and associations/ relationships: Tables: users, addresses, addresstypes Models: User, Address, Addresstype With associations/relationships: User hasMany/belongsTo Address Address belongsTo/hasMany Addresstype Where addresstypes identifies whether an address is a private address or a company address (and others if necessary). Thus in a form, the user enters the address, and chooses the addresstype, saves, and all is well :) Would the above satisfy your requirements? Enjoy, John On Feb 5, 9:26 pm, Robert K wrote: > user needs to store addresses. > Address table can store addresses for any type of relationship, users, > companies, etc. > > user_addresses, > company_addresses, ... > > addresses table (id,address1,address2,city,zip,...) > > user_addresses (id,user_id,address_id) > company_addresses (id,company_id,address_id) > > so when creating a user, what will happen is not only will cake create > the relationship bonding in the _addresses table, but also > creating the address record in the addresses table. > > I could not figure out a legitimate way in cakePHP to do this with the > saveAll function. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: friends and self HABTM
Your data structure for saving should look like this: array ( [User] => array ( [id] => 999 ) [Friend] => array ( [id] => 888 ) ) so do this: [code] if (!empty($this->data)) { $this->data['User']['id'] = $this->Auth->user('id'); if ( $this->User->save( $this->data ) ) { ... [/code] and change your view accordingly! That should be the correct way for saving the HABTM data that you have. Enjoy, John On Feb 5, 12:42 am, Foroct wrote: > I am trying to build a simple social network type site where a user > can friend another user. I realize this has been discussed before, a > lot, but none of the discussions on here really point out my issue so > I thought someone might be able to shine some light on where I am > going astray. > > My user model > > var $hasAndBelongsToMany = array( > 'Friend' => array ( > 'className' => 'User', > 'joinTable' => 'users_users', > 'foreignKey' => 'user_id', > 'associationForeignKey' => 'friend_id' > ) > ); > > My users_controler addfriend fuction > > function addfriend() { > if (!empty($this->data)) { > $user_id = $this->Auth->user('id'); // sets user_id > in friend table > to authed user > //debug($this->data);exit; > if ($this->User->UsersUser->save($this->data)) > { > $this->Session->setFlash(__('The User has > been saved', true)); > $this->redirect($this->referer()); > > } else { > $this->Session->setFlash(__('The User > could not be saved. Please, try again.', true)); > debug($this->data);exit; > } > } > } > > My old school form on the user/view page for adding a user just so i > can see whats going on for now > > name="_method" > value="POST" /> > value=" echo( $auth['User']['id']); ?>" id="user_id" /> > type="text" value=" echo( $user['User']['id']); ?>" id="friend_id" /> > > end('Submit');?> > > I have a database table called users_users with an id, user_id, and > friend_id columns. When I manually input data everything works fine. > So I know my associations are proper. > > However, when I submit my form with known good information nothing > goes into the database table. So I debuged the data that I am passing > to from the addfriend function and I get the following: > > app/controllers/users_controller.php (line 402) > > Array > ( > [Users_users] => Array > ( > [user_id] => 1 > [friend_id] => 79 > ) > > ) > > If anyone could point out what might be going wrong I would greatly > appreciate it. > > Thanks. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
hasMany join table that stores the actual ForeignKey
user needs to store addresses. Address table can store addresses for any type of relationship, users, companies, etc. user_addresses, company_addresses, ... addresses table (id,address1,address2,city,zip,...) user_addresses (id,user_id,address_id) company_addresses (id,company_id,address_id) so when creating a user, what will happen is not only will cake create the relationship bonding in the _addresses table, but also creating the address record in the addresses table. I could not figure out a legitimate way in cakePHP to do this with the saveAll function. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: friends and self HABTM
Bump- Can anyone provide some insight on this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
How create a unique default.ctp in plugins for all apps?
We have multiple applications reading a plugin. How to define that all applications to use as a ctp layout? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: Tabs jquery with CakePHP
Start by looking here: http://bakery.cakephp.org/articles/view/simple-tabhelper-using-jquery-ui and also, Google is your friend :) Enjoy, John On Feb 5, 6:29 pm, Mistoo wrote: > Hi, I looking for a source code, link, some example ... To understand > how work Tabs > jquery with CakePHP. There anybody can to help me. Thanks in advance Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: List of models
If that doesn't work (it might only return from the given context), you might need to look in to the ConnectionManager Class: http://api.cakephp.org/class/connection-manager -- I'd definitely try out Dr. Loboto's suggestion first though as it would be very easy to test out. On Feb 4, 10:50 pm, "Dr. Loboto" wrote: > Try Configure::listObjects('model') > > On Feb 4, 11:25 am, Stevil wrote: > > > > > I've only just started learning cake recently, so sorry if this > > question has been asked before as I've got no idea what to search for. > > Basically what I'm trying to do is find all the models in the system. > > I'm working on a system which auto generates menus for the different > > models. I'm sure I could read through the files inside the models > > directory to get them, but I thought there might be a better way?- Hide > > quoted text - > > - Show quoted text - Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Example de formulaire Cakephp avec Tabs & jquery
Bonjour, je viens de débuter avec CakePHP en version 1.2.4, et je cherche des examples de codes, lien, ... pour utiliser Cakephp avec Tabs & jquery. Merci Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Tabs jquery with CakePHP
Hi, I looking for a source code, link, some example ... To understand how work Tabs jquery with CakePHP. There anybody can to help me. Thanks in advance Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: Organizing controllers in folders
Yes all you need to do is create the directories and move your controllers. CakePHP will find the files and cache the paths. Make sure you are developing with debug > 0 so the cache file will be refreshed as you move your files around. -- /** * @author Larry E. Masters * @var string $userName * @param string $realName * @returns string aka PhpNut * @access public */ On Fri, Feb 5, 2010 at 9:30 AM, Mandy Singh wrote: > hi, > > is it possible to organize controllers under /app/controllers in sub- > folders ? > > my module is growing huge and i would like to create sub directories > under /app/controllers like "components" . > > let me know. > > i am on cakephp 1.2. > > thanks. > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: migrate from 1.2.3 -> 1.2.6
On 2/4/2010 9:18 PM, Alexandru wrote: i sow some migration guided for 1.2.4 and 1.2.5 but now i can't find them anymore because track cake move to another platform. anyone know where are the old migration guides? Alex, you don't need migration guides. Anyone on this list can confirm that such an upgrade is painless. Make a backup and give it a try. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: Organizing controllers in folders
Hi Mandy Singh, I hope this would help you... http://bakery.cakephp.org/articles/view/flexible-controller-and-modelpaths just add another path... enableSubFoldersOn(ROOT.DS.APP_DIR.'/controllers', $controllerPaths); enableSubFoldersOn(ROOT.DS.APP_DIR.'/controllers/(subfolder)', $controllerPaths); On Fri, Feb 5, 2010 at 10:30 AM, Mandy Singh wrote: > > hi, > > is it possible to organize controllers under /app/controllers in sub- > folders ? > > my module is growing huge and i would like to create sub directories > under /app/controllers like "components" . > > let me know. > > i am on cakephp 1.2. > > thanks. > > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. > > 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.comFor > more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Organizing controllers in folders
hi, is it possible to organize controllers under /app/controllers in sub- folders ? my module is growing huge and i would like to create sub directories under /app/controllers like "components" . let me know. i am on cakephp 1.2. thanks. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: Problem with sql joins in relations when not following cakephp conventions
I would think from what I have studied in the CakePHP manual, that your solution is not easy. One way may be for you to define the joins yourself in the find as specified here: http://book.cakephp.org/view/78/Associations-Linking-Models-Together#Joining-tables-872 Enjoy, John On Feb 5, 3:49 pm, doze wrote: > Hello, > > I have following database tables that are defined by the customer and > cannot be changed: > > |---| > | Tuopak | > |---| > | id (primarykey) | > | tuopaknro | > | name | > | | > | | > |---| > > |--| > | Tuopakriv | > |--| > | id (primarykey) | > | tuopaknro | > | num | > | | > | | > |--| > > The tables have a relation Tuopak hasMany Tuopakriv with tuopaknro > field. > > So the primaryKey field is not used as the relation key. > > When I try to define the relations like so: > > class Tuopak extends AppModel { > var $name = 'Tuopak'; > var $useTable = 'tuopak'; > var $actsAs = array('Containable'); > var $deletedRecord = null; > > var $hasMany = array( > 'Tuopakriv' => array( > 'className' => 'Tuopakriv', > 'foreignKey' => false, > 'conditions' => 'Tuopak.tuopaknro = Tuopakriv.tuopaknro' > ) > ); > ?> > > And when querying for Tuopak records, I get an SQL error about missin > Tuopakriv.tuopaknro column because Cake is not joining the Tuopak and > Tuopakriv tables for the query. > > If I use $primaryKey variable in the model, e.g. define 'tuopaknro' as > the primary key for both models, remove the conditions from the > hasMany definition and define 'tuopaknro' as the foreign key, then > cake does the joins, but then all editing and adding fails records. > > Is there a way to keep the hasMany definition like described above, > but tell cake to join the tables when querying? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
deprecation and forward migration question
We are working on moving a giant app foward from 1.2.5875 pre-beta to the latest stable 1.2. When we last scoped this out a year ago ago to assess the effort all findAll calls etc were triggering the deprecation error code. When we downloaded the latest stable cake we noticed the deprecation trigger errors are commented out. Was this a decision not to actually force migration forward and allow the old API to continue forward? Thanks in advance - we're moving forward we just want to do it right while obviously not changing things that are no longer really deprecated. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Problem with sql joins in relations when not following cakephp conventions
Hello, I have following database tables that are defined by the customer and cannot be changed: |---| | Tuopak | |---| | id (primarykey) | | tuopaknro | | name | | | || |---| |--| | Tuopakriv | |--| | id (primarykey) | | tuopaknro | | num | | | | | |--| The tables have a relation Tuopak hasMany Tuopakriv with tuopaknro field. So the primaryKey field is not used as the relation key. When I try to define the relations like so: array( 'className' => 'Tuopakriv', 'foreignKey' => false, 'conditions' => 'Tuopak.tuopaknro = Tuopakriv.tuopaknro' ) ); ?> And when querying for Tuopak records, I get an SQL error about missin Tuopakriv.tuopaknro column because Cake is not joining the Tuopak and Tuopakriv tables for the query. If I use $primaryKey variable in the model, e.g. define 'tuopaknro' as the primary key for both models, remove the conditions from the hasMany definition and define 'tuopaknro' as the foreign key, then cake does the joins, but then all editing and adding fails records. Is there a way to keep the hasMany definition like described above, but tell cake to join the tables when querying? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: help!
Is there a question here that I missed? The first thing to do is check out http://cakephp.org ... that's the first place you should go. It has plenty of documents, books, tutorials, and walk-throughs. I think everyone on this group could contest that it does have a bit of a learning curve. Especially if you are coming from a long engrained "classic" PHP development style. Getting the hang of how a Model / View / Controller (MVC) system works. If you have specific questions you have come to the right spot, other than that I would look at cake's site and start to play with it. Chad On Feb 4, 12:24 pm, Ala Crhisostemo Junior wrote: > hello > 'm good study information systems > and I'm beginning to study cakePHP > I already work with php, > ta but not easy to get the hang of, > I'm not as Concegua entente > the cake works, and how do I use it, > can someone give me a hand? > > thanks > > --http://twitter.com/alaiRc Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: how to validate two unique fields together?
matzehahn Thanks for this link. Unfortunately this source don't worked with my edit-function (add worked). I tryed to change the source, but without success. BrendonKoz Thanks also for your help. I tryed some hours to get all this working but also without success. Fortunately, i found a link to a nice validate function: (http:// bin.cakephp.org/view/653776884 -> Thanks a lot to the author!!!) This code works for my with add and edit. I simply included a 'notEmpty' rule and it was done. :) So here is my source: [code] var $validate = array( 'location_id' => array( /* In the parameters, after 'description', there can be added more fields to validate */ 'rule' => array('noDuplicates', array('description', 'location_id')), 'message' => 'this combination of Location and Description is already in use' ), 'description' => array( 'rule' => 'notEmpty', 'message' => '"Description" cannot be left blank' ) ); /* Checks to see if there is already a duplicate of the specific combination of fields */ function noDuplicates($value, $params) { /* if editing an existing record then don't count this record in the check for duplicates */ if (!empty($this->id)) $conditions[] = array($this->primaryKey . ' <>' => $this- >id); /* Add a condition for each field we want to check against */ foreach ($params as $field) { /* check if value is empty. if it is then check for a NULL value against this field */ if($this->data[$this->name][$field]) $fieldVal = $this->data[$this->name][$field]; else $fieldVal = null; $conditions[] = array($field => $fieldVal); } $existingFieldsCount = $this->find( 'count', array('conditions' => $conditions, 'recursive' => -1) ); return $existingFieldsCount < 1; } [\code] The function can by included in the current model or in the app_model. Greetings! :) Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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