Hi, I have an odd validation issue I can't work out.
I have the following form built using the form helper;
==
<?php echo $this->Form->create('Account');?>
<fieldset>
<legend><?php __('Register Account'); ?></legend>
<?php echo $this->Form->input('username', array('id' =>
'global_accounts_Username', 'div' => 'v input', 'label' =>
array('text' => 'Username', 'class' => 'label'))); ?>
<p>Can be any length but only contain letters and numbers.
No spaces, hyphens or underscores allowed.</p>
<?php echo $this->Form->input('password', array('id' =>
'global_accounts_Password', 'div' => 'v input', 'label' =>
array('text' => 'Password', 'class' => 'label'), 'after' => '<p
class=pw_push><span>Time needed to crack password,  </span> <span
id=global_accounts_Password-strength></span></p>')); ?>
<p>Can contain any type of character but must be over 6
characters in length. It is recommended to use punctuation or a full
sentence. </p>
<?php echo $this->Form->input('email', array('id' =>
'global_accounts_Email', 'div' => 'v input', 'label' => array('text'
=> 'E-mail', 'class' => 'label'))); ?>
<p>Must exist and be accessible, a conformation e-mail
will be sent to this address as well as any account notifications.</p>
<?php echo $this->Form->input('first_name', array('id' =>
'global_accounts_FirstName', 'div' => 'v input', 'label' =>
array('text' => 'First name', 'class' => 'label'))); ?>
<p>If you are an individual please enter your first name,
only letters are allowed.</p>
<?php echo $this->Form->input('second_name', array('id' =>
'global_accounts_SecondName', 'div' => 'v input', 'label' =>
array('text' => 'Second name', 'class' => 'label'))); ?>
<p>If you are an individual please enter your second name,
only letters are allowed.</p>
<?php echo $this->Form->input('company_name', array('id' =>
'global_accounts_CompanyName', 'div' => 'v input', 'label' =>
array('text' => 'Company name', 'class' => 'label'))); ?>
<p>If you are a business please enter your business name,
only letters, numbers and spaces are allowed.</p>
<?php echo $this->Form->input('terms_accepted', array('id' =>
'global_accounts_TermsAccepted', 'div' => 'v input', 'label' =>
array('text' => 'Accept terms', 'class' => 'label_left'))); ?>
<p>To open an account you MUST agree to these terms and
conditions and Privacy policy</p>
</fieldset>
<?php echo $this->Form->end(__('Register account', true));?>
==
This is validated by the following validation rules in the 'Account'
model.
==
var $validate = array(
'username' => array(
'rule' => 'alphaNumeric',
'message' => 'Usernames can only contain letters and
numbers.',
'allowEmpty' => false
),
'password' => array(
'rule' => array('minlength', 6),
'message' => 'Passwords must be six (6) characters or
more.',
'allowEmpty' => false
),
'email' => array(
'rule' => 'email',
'message' => 'Email must be valid.',
'allowEmpty' => false
),
'first_name' => array(
'rule' => array('custom' => '^[a-zA-Z]+(([\'\,\.\-][a-
zA-Z])?[a-zA-Z]*)*$'),
'message' => 'Names can only contain letters.',
'allowEmpty' => false
),
'second_name' => array(
'rule' => array('custom' => '^[a-zA-Z]+(([\'\,\.\-][a-
zA-Z])?[a-zA-Z]*)*$'),
'message' => 'Names can only contain letters.',
'allowEmpty' => false
),
'company_name' => array(
'rule' => array('custom' => '(\w(\s)?)+'),
'message' => 'Company names can only contain letters,
numbers and spaces.'
),
'terms_accepted' => array(
'rule' => array('comparison', '!=', '>0'),
'required' => true,
'message' => 'You must agree to the terms and conditions
and privacy policy.',
'on' => 'create'
)
);
==
The problem is whenever the form is submitted I get this error back;
==
Notice (8): Undefined offset: 0 [CORE/cake/libs/model/model.php, line
2550]
Warning (512): Could not find validation handler for first_name [CORE/
cake/libs/model/model.php, line 2573]
Warning (512): Could not find validation handler for second_name
[CORE/cake/libs/model/model.php, line 2573]
Warning (512): Could not find validation handler for company_name
[CORE/cake/libs/model/model.php, line 2573]
==
I don't know why it doesn't like these fields, they are named the same
in the database, form and validation rule let it doesn't seem to like
it. The data is saved correctly to the database when supplied so that
isn't an issue. Does anyone know a way around this?
Thanks, Felix
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 [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