I have a big problem with data validation in cakePHP 1.1
My tagErrorMsg() validation messages do not show up in the view, here
is an overview over the situation:
I have a User model and a Pupil model.
Associations exist between User and Pupil: User hasOne Pupil; Pupil
belongsTo User
In addition to these associations the 'User' is also present in the
AppController's $uses array (see code snippet in the appendix at the
end of this post). It is needed somewhere else for getting the data
to send emails.
Validation rules are set inside the models (see appendix).
There is a page pupils/add which has a form with fields for user data
and fields for pupil data.
Now the problem is that when entering invalid data into the user
fields the error messages (tagErrorMsg) in the view are not displayed
although the respective fields are marked as invalid in the
validationErrors array.
I know that the above mentioned 'User' entry in the AppController's
$uses array is to blame for this because everything works fine without
this entry.
However the 'User' is needed in the AppController - I cannot leave it
out there (it is of vital importance for my Email component).
Can anyone help me fixing this problem, please? I have absolutely no
idea what causes this problem.
Appendix:
The involved files are (code snippets):
The uses array in the AppController has to contain the 'User' entry
because it is needed for sending emails.
AppController app_controller.php:
class AppController extends Controller
{
var $uses = array('Logging','Email','Configuration',
'Confirmation','User');
...
}
User model user.php
class User extends AppModel
{
var $validate = array(
'username' => '/([^\d\s_]+)[a-zA-Z\d_]+$/',
'passwort' => VALID_NOT_EMPTY,
'email' => VALID_NOT_EMPTY,
);
var $hasOne = array(
'Pupil' => array('className' => 'Pupil',
'foreignKey' =>
'user_id',
'dependent' =>
true,),
);
...
}
Pupil model pupil.php
class Pupil extends AppModel
{
var $validate = array(
'plz' => '^\d{5}$^',
'vorname' => VALID_NOT_EMPTY,
'nachname' => VALID_NOT_EMPTY,
'ort' => VALID_NOT_EMPTY,
'strasse' => VALID_NOT_EMPTY,
'geschlecht' => VALID_NOT_EMPTY,
'geburtsdatum' => VALID_NOT_EMPTY,
'last_class' => VALID_NOT_EMPTY,
);
var $belongsTo = array(
'User' => array('className' => 'User',
'foreignKey' =>
'user_id',
'dependent' =>
true),
);
...
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---