For some reason I can't get my error messages for validations to work.
I tried outputting the validations by doing:
pr($this->validationErrors);
But all I get is an empty array. What do you guys see that I'm doing
wrong?
Thanks,
Tony
Here's my model:
================
class User extends AppModel {
var $name = 'User';
// This model is a self-join
var $belongsTo = array(
'ParentMember'
=> array(
'className' => 'User',
'foreignKey' => 'parent_id'),
);
var $hasMany = array(
'ChildMember'
=> array(
'className' => 'User',
'foreignKey' => 'parent_id'),
);
// Place the validation rules here:
var $validate = array(
'first_name' => array(
'rule' => 'alphaNumeric',
'required' => true,
'message' => 'Name is required. Please enter
your first name.',
'last' => true
),
'email' => array(
'rule' => array('email', true),
'required' => true,
'message' => 'Email is required. Please enter
your email
address.',
'last' => true
),
'phone' => array(
'rule' => array('phone', null, 'us'),
'message' => 'Phone number is not valid. Please
enter valid phone
number.',
'last' => true
)
);
}
================
Here's my controller with the method action it's being submitted to:
================
function thank_you()
{
$member = $this->Session->read('teamMember');
$this->set('pageTitle', 'Before you leave TriVita Cooperative
Marketing\'s website');
$this->set('bigTitle', 'BEFORE YOU LEAVE<br />A SPECIAL THANK
YOU<br /> FROM ME...');
$this->set('member', $member);
if( !empty($this->data) )
{
$this->User->create();
if( $this->User->save($this->data) )
{
$tony = $this->User->findByAffiliateNumber
('11167706');
$prospect =
$this->User->findById($this->User->id);
$this->set('prospectName', $prospect['User']
['first_name']);
$this->set('tonyEmail', $tony);
if( $prospect['User']['email'] != '' ||
$prospect['User']
['email'] != null )
{
$this->_sendThankYouEmail($prospect,
$member);
}
/*
if( $member['User']['affiliate_number'] !=
'11167706')
{
$this->_sendMemberNotificationEmail($prospect, $member, $tony);
}
*/
$this->_sendMemberNotificationEmail($prospect,
$member, $tony);
$this->_sendTonyEmail($prospect, $member,
$tony);
}
else
{
$this->redirect(array('action' => 'index'),null,true);
}
}
else
{
// we're at this place because a form was not filled in
$this->redirect(array('action' => 'index'),null,true);
}
}
================
Here's my view form:
================
echo $form->create('User', array('url' => '/businesses/thank_you'));
echo $form->hidden('parent_id', array('value' =>
$member['User']['id']));
echo '<span class="required">*</span> <span>Name:</
span>';
echo $form->input('first_name', array('label' =>
false, 'size' => 20, 'error' => array('wrap' => 'span', 'class' =>
'errorMsg') ));
echo $form->error('first_name');
echo '<span class="required">*</span>
<span>Email:</span>';
echo $form->input('email', array('label' => false,
'size' => 20));
echo '<span><strong>Phone: <em>(optional, for
those who really want change)</em></strong></span><br />';
echo $form->input('phone', array('label' =>
false));
echo '<br />';
echo $form->end(array('label' => 'I Want Change in
My Life'));
================
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---