I've a not common problem to do a form validation.
First let me explain a part of the problem: I'm doing a cakePhp website, this website will be used to sell product to customer. To do this, we have two database: one database(database A) relative to products, customer references, bills(provided by the ERP), and one database (database B)relative to information that the website has to store only for the website(passwords of users, cart content, comments on a products, ...).
To register ONE user on our website, I've to: Create one "address" in the database A Create one "customer" in the database A Create one "user" in the database B.
This has to be only one action.
I'm on the user controller, so no problem to validate every fields of the "user", but how to make this form validate all constraints I have in my customer and address models?
The problem is that because user and customer are not in the same database, I can't(in fact I'm not sure of that, but it seems to be logic, because of automatic Left join) declare the $belongsTo and $hasOne relationship between user and customer.
So how could I make the check of 开发者_JS百科those constraints? Thank you very much
You can validate fields manually.
$this->Customer->set( $this->data );
$this->Address->set( $this->data );
if( $this->User->validates() && $this->Customer->validates() && $this->Address->validates() ) {
// save data
}
精彩评论