-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Show error message in cakephp validation #2
Comments
Please show me view and Model::$validate code. |
There's the same problem with auth's flashes. My Validate code : <?php
class User extends AppModel{
public $validate = array(
'username' => array(
'alpha' => array(
'rule' => '/^[a-z0-9-A-Z]*$/',
'message' => 'Username is not valid'
),
'uniq' => array(
'rule' => 'isUnique',
'message' => "The Username is already used"
)
),
'mail' => array(
'mail' => array(
'rule' => 'email',
'message' => 'Mail is not valid'
),
'uniq' => array(
'rule' => 'isUnique',
'message' => 'This Mail Address is already used'
)
),
'password' => array(
'rule' => 'notEmpty'
),
'password2' => array(
'rule' => 'identicalFields'
)
);
public function identicalFields($check, $limit){
return $check['password2'] == $this->data['User']['password'];
}
} |
It is displayed as this in my environment Model/User.php <?php
class User extends AppModel {
public $validate = array(
'username' => array(
'alpha' => array(
'rule' => '/^[a-z0-9-A-Z]*$/',
'message' => 'Username is not valid'
),
'uniq' => array(
'rule' => 'isUnique',
'message' => "The Username is already used"
)
),
'mail' => array(
'mail' => array(
'rule' => 'email',
'message' => 'Mail is not valid'
),
'uniq' => array(
'rule' => 'isUnique',
'message' => 'This Mail Address is already used'
)
),
'password' => array(
'rule' => 'notEmpty'
),
'password2' => array(
'rule' => 'identicalFields',
'message' => 'Password is not same'
)
);
public function identicalFields($check, $limit) {
return $check['password2'] === $this->data['User']['password'];
}
} View/Users/add.ctp <?php echo $this->Form->create('User', array(
'inputDefaults' => array(
'div' => 'control-group',
'label' => array(
'class' => 'control-label'
),
'wrapInput' => 'controls'
),
'class' => 'form-horizontal'
)); ?>
<?php echo $this->Form->input('username'); ?>
<?php echo $this->Form->input('mail'); ?>
<?php echo $this->Form->input('password'); ?>
<?php echo $this->Form->input('password2', array('type' => 'password')); ?>
<?php echo $this->Form->submit('Submit', array(
'div' => 'form-actions',
'class' => 'btn'
)); ?>
<?php echo $this->Form->end(); ?> It mean message of password2? |
@Kareylo Auth flash setting class AppController extends Controller {
public $components = array(
'Auth' => array(
'flash' => array(
'element' => 'alert',
'key' => 'auth',
'params' => array('plugin' => 'BoostCake', 'class' => 'alert-error')
)
)
);
} |
@Kareylo, If you want error color, it need that Yes, I should add doc soon later :) |
With |
Ok, sorry I have not checked this issue last a few days |
Hi I am having the same trouble:
register.ctp:
User.php:
|
I try to implement field in bootsrap like Html->input helper in original cakephp.
In original field, if the value empty or value is invalid from model, the field in view is automatically show error message.
I try in example in BoostCakePassword field, but if my field is empty or value is invalid it's not showing the error message :(
I missing something, or the cakephp validation is not connected with this plugin ?
The text was updated successfully, but these errors were encountered: