本文整理汇总了PHP中AppModel::beforeValidate方法的典型用法代码示例。如果您正苦于以下问题:PHP AppModel::beforeValidate方法的具体用法?PHP AppModel::beforeValidate怎么用?PHP AppModel::beforeValidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppModel
的用法示例。
在下文中一共展示了AppModel::beforeValidate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeValidate
public function beforeValidate($options = array())
{
parent::beforeValidate($options);
$this->validate['Name']['notempty']['message'] = __d('contactform', 'please insert your name');
$this->validate['Mail']['email']['message'] = __d('contactform', 'please insert your email address');
$this->validate['Message']['notempty']['message'] = __d('contactform', 'please enter your message');
}
示例2: beforeValidate
public function beforeValidate()
{
parent::beforeValidate();
if (isset($this->data[$this->alias]['url']) && !isset($this->data[$this->alias]['study_name'])) {
$this->data[$this->alias]['study_name'] = $this->getTitle($this->data[$this->alias]['url']);
}
if (isset($this->data[$this->alias]['tag_list'])) {
preg_match_all('/\\[([^\\]]*)\\]/', $this->data[$this->alias]['tag_list'], $matches);
if (isset($matches[1])) {
$this->data['Tag']['Tag'] = array();
foreach ($matches[1] as $tag) {
$tagValue = mb_convert_kana($tag, 'as');
$conditions = array('LOWER(Tag.tag)' => strtolower($tagValue));
$this->Tag->contain();
$this->Tag->foreignKey();
$tag_id = $this->Tag->field('id', $conditions);
if (!$tag_id) {
$data = array('Tag' => array('tag' => $tagValue));
$this->Tag->create();
if (!$this->Tag->save($data)) {
return false;
}
$tag_id = $this->Tag->getInsertID();
}
$this->data['Tag']['Tag'][] = $tag_id;
}
}
unset($this->data[$this->alias]['tag_list']);
}
return true;
}
示例3: beforeValidate
/**
* Handle beforeValidate callback
*
* @return void
* @author hungnq
**/
public function beforeValidate($options = array())
{
if (isset($this->data[$this->name]['tel']) && is_array($this->data[$this->name]['tel'])) {
$this->data[$this->name]['tel'] = implode('', array_filter($this->data[$this->name]['tel']));
}
return parent::beforeValidate($options);
}
示例4: beforeValidate
function beforeValidate()
{
if (!parent::beforeValidate()) {
return false;
}
$this->loadValidation();
}
示例5: beforeValidate
/**
* beforeValidate callback
*
* @param array $options
* @return boolean
* @access public
* @todo implement check of approved_from/approved_to
*/
public function beforeValidate($options = array())
{
if (!parent::beforeValidate($options)) {
return false;
}
return true;
}
示例6: beforeValidate
/**
* CakePHP's beforeValidate callback.
*
* @return boolean
* @access public
*/
public function beforeValidate()
{
parent::beforeValidate();
if (!empty($this->data)) {
/**
* An empty password value is never empty. The Auth module hashes
* the empty value which makes it non-empty and fools the notEmpty
* validation rule. This is bad.
*
* We want to recognize an empty password when we see one and
* throw it out, so we have to make that adjustment manually.
*/
$empty_password = Security::hash('', null, true);
if (isset($this->data[$this->alias]['password']) && $this->data[$this->alias]['password'] === $empty_password) {
if (!empty($this->id)) {
# When editing, just remove the data so no change is attempted.
unset($this->data[$this->alias]['password']);
unset($this->data[$this->alias]['confirm_password']);
} else {
# When creating, empty the value so it will be caught by validation.
$this->data[$this->alias]['password'] = '';
$this->data[$this->alias]['confirm_password'] = '';
}
}
}
return true;
}
示例7: beforeValidate
public function beforeValidate($options = array())
{
parent::beforeValidate();
if ($this->data['User']['password'] == '') {
unset($this->data['User']['password']);
}
return true;
}
示例8: beforeValidate
/**
* Before Validation
* @param array $options
* @return boolean
*/
public function beforeValidate($options = array())
{
// ignore empty file - causes issues with form validation when file is empty and optional
if (!empty($this->data[$this->alias]['filename']['error']) && $this->data[$this->alias]['filename']['error'] == 4 && $this->data[$this->alias]['filename']['size'] == 0) {
unset($this->data[$this->alias]['filename']);
}
parent::beforeValidate($options);
}
示例9: beforeValidate
public function beforeValidate($options = array())
{
parent::beforeValidate($options);
if (isset($this->data[$this->alias]['product_exchange_id'])) {
$product = $this->ProductExchange->find('first', array('recursive' => -1, 'conditions' => array('ProductExchange.id' => $this->data[$this->alias]['product_exchange_id']), 'fields' => array('point_fee', 'money_fee', 'point_exchange', 'product_category_id', 'min_point_gift', 'min_point_money', 'exchange_gift_rate')));
$this->data['ProductExchange'] = array('point_fee' => intval($product['ProductExchange']['point_fee']), 'money_fee' => intval($product['ProductExchange']['money_fee']), 'point_exchange' => $product['ProductExchange']['point_exchange'], 'product_category_id' => $product['ProductExchange']['product_category_id'], 'min_point_gift' => intval($product['ProductExchange']['min_point_gift']), 'min_point_money' => intval($product['ProductExchange']['min_point_money']), 'exchange_gift_rate' => $product['ProductExchange']['exchange_gift_rate']);
}
}
示例10: beforeValidate
public function beforeValidate($options = array())
{
if (isset($this->data[$this->alias]['email'])) {
// Always store email in lowercase
$this->data[$this->alias]['email'] = strtolower($this->data[$this->alias]['email']);
}
return parent::beforeValidate($options);
}
示例11: beforeValidate
public function beforeValidate($options = array())
{
parent::beforeValidate();
$date = date('Y-m-d H:i:s');
if (empty($this->data['EventBlacklist']['id'])) {
$this->data['EventBlacklist']['date_created'] = $date;
}
return true;
}
示例12: beforeValidate
public function beforeValidate($options = array())
{
$name = $this->data[$this->alias]['name'];
switch ($name) {
default:
break;
}
return parent::beforeValidate($options);
}
示例13: beforeValidate
/**
* Called during validation operations, before validation. Please note that custom
* validation rules can be defined in $validate.
*
* @param array $options Options passed from Model::save().
* @return bool True if validate operation should continue, false to abort
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
* @see Model::save()
*/
public function beforeValidate($options = array())
{
$forgotPass = CakeSession::read('ForgotPass');
if (!$forgotPass) {
$forgotPass = array();
}
$this->validate = Hash::merge($this->validate, array('email' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Please input %s.', __d('auth', 'email')), 'required' => false), 'email' => array('rule' => array('email'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('auth', 'email'), __d('auth', 'email')))), 'authorization_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Please input %s.', __d('auth', 'Authorization key')), 'required' => false), 'equalTo' => array('rule' => array('equalTo', Hash::get($forgotPass, 'authorization_key')), 'message' => __d('auth', 'Failed on validation errors. Please check the authorization key.'), 'required' => false))));
return parent::beforeValidate($options);
}
示例14: beforeValidate
/**
* Called during validation operations, before validation. Please note that custom
* validation rules can be defined in $validate.
*
* @param array $options Options passed from Model::save().
*
* @return boolean True if validate operation should continue, false to abort
* @see Model::save()
*/
public function beforeValidate($options = [])
{
parent::beforeValidate($options);
if (Router::getParam('action') == 'admin_profile') {
if ($this->data['User']['password'] == "" && $this->data['User']['confirm_password'] == "") {
unset($this->data['User']['password']);
unset($this->data['User']['confirm_password']);
}
}
}
示例15: beforeValidate
/**
* Antes de validar as informações
*
* @return boolean
*/
public function beforeValidate($options = array())
{
if (isset($this->data[$this->alias]['twitter'])) {
$twitter = $this->data[$this->alias]['twitter'];
$twitter = trim($twitter);
$twitter = trim($twitter, '@');
$this->data[$this->alias]['twitter'] = $twitter;
}
return parent::beforeValidate($options);
}