当前位置: 首页>>代码示例>>PHP>>正文


PHP Validation::label方法代码示例

本文整理汇总了PHP中Validation::label方法的典型用法代码示例。如果您正苦于以下问题:PHP Validation::label方法的具体用法?PHP Validation::label怎么用?PHP Validation::label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validation的用法示例。


在下文中一共展示了Validation::label方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 public function validate(CM_Form_Abstract $form)
 {
     if ($this->_extra_validation) {
         $values = array();
         foreach ($form->get_values() as $name => $value) {
             $values[$name] = $value->get_raw();
             $this->_extra_validation->label($name, $form->get_field($name)->get_label());
         }
         // Validation только read-only, поэтому создаем новый объект
         $this->_extra_validation = $this->_extra_validation->copy($values);
     }
     try {
         $this->get_model()->check($this->_extra_validation);
     } catch (ORM_Validation_Exception $e) {
         $errors = $e->errors('validation');
         if ($external = arr::get($errors, '_external')) {
             $errors = arr::merge($errors, $external);
             unset($errors['_external']);
         }
         foreach ($errors as $name => $error) {
             $form->get_field($name)->set_error($error);
         }
         return FALSE;
     }
     return TRUE;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:26,代码来源:ORM.php

示例2: validate

 public function validate(CM_Form_Abstract $form)
 {
     $values = array();
     foreach ($form->get_values() as $name => $value) {
         $values[$name] = $value->get_raw();
         $this->_validation->label($name, $form->get_field($name)->get_label());
     }
     // Validation только read-only, поэтому создаем новый объект
     $this->_validation = $this->_validation->copy($values);
     if ($this->_validation->check()) {
         return TRUE;
     }
     foreach ($this->_validation->errors('validation') as $name => $error) {
         $form->set_error($name, $error);
     }
     return FALSE;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:17,代码来源:Validate.php

示例3: _validation

 /**
  * Initializes validation rules, and labels
  *
  * @return void
  */
 protected function _validation()
 {
     // Build the validation object with its rules
     $this->_validation = Validation::factory($this->_object)->bind(':model', $this)->bind(':original_values', $this->_original_values)->bind(':changed', $this->_changed);
     foreach ($this->rules() as $field => $rules) {
         $this->_validation->rules($field, $rules);
     }
     // Use column names by default for labels
     $columns = array_keys($this->_table_columns);
     // Merge user-defined labels
     $labels = array_merge(array_combine($columns, $columns), $this->labels());
     foreach ($labels as $field => $label) {
         $this->_validation->label($field, $label);
     }
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:20,代码来源:orm.php

示例4: _add_rules

 /**
  * Add rules to the validation object
  *
  * @access protected
  * @param mixed Formo_Container $field. (default: NULL)
  * @return void
  */
 protected function _add_rules(Validation $validation)
 {
     if (!($rules = $this->get('rules'))) {
         // Only do anything if the field has rules
         return;
     }
     $validation->label($this->alias(), $this->view()->label());
     $validation->rules($this->alias(), $rules);
 }
开发者ID:kanikaN,项目名称:qload,代码行数:16,代码来源:validator.php

示例5: test_check

 /**
  * Tests Validation::check()
  *
  * @test
  * @covers Validation::check
  * @covers Validation::rule
  * @covers Validation::rules
  * @covers Validation::errors
  * @covers Validation::error
  * @dataProvider provider_check
  * @param array   $array            The array of data
  * @param array   $rules            The array of rules
  * @param array   $labels           The array of labels
  * @param boolean $expected         Is it valid?
  * @param boolean $expected_errors  Array of expected errors
  */
 public function test_check($array, $rules, $labels, $expected, $expected_errors)
 {
     $validation = new Validation($array);
     foreach ($labels as $field => $label) {
         $validation->label($field, $label);
     }
     foreach ($rules as $field => $field_rules) {
         foreach ($field_rules as $rule) {
             $validation->rule($field, $rule[0], $rule[1]);
         }
     }
     $status = $validation->check();
     $errors = $validation->errors(TRUE);
     $this->assertSame($expected, $status);
     $this->assertSame($expected_errors, $errors);
     $validation = new validation($array);
     foreach ($rules as $field => $rules) {
         $validation->rules($field, $rules);
     }
     $validation->labels($labels);
     $this->assertSame($expected, $validation->check());
 }
开发者ID:EhteshamMehmood,项目名称:BlogMVC,代码行数:38,代码来源:ValidationTest.php

示例6: validate

 /**
  * Validate the data, returning array of errors (if any).
  *
  * @return array
  */
 public function validate()
 {
     $validation = new Validation($this->_data);
     foreach ($this->_fields as $fieldName => $fieldOptions) {
         foreach (Arr::get($fieldOptions, 'rules', array()) as $fieldRule) {
             if (is_array($fieldRule)) {
                 // Take the 1st param as the name, the rest as params.
                 $ruleName = array_shift($fieldRule);
                 $ruleParams = $fieldRule;
             } else {
                 // Just use the rule as passed with no params.
                 $ruleName = $fieldRule;
                 $ruleParams = NULL;
             }
             // Check if the named function is actually a method on this object.
             if (!function_exists($ruleName) && method_exists($this, $ruleName)) {
                 $ruleName = array($this, $ruleName);
             }
             $validation->rule($fieldName, $ruleName, $ruleParams);
             $validation->label($fieldName, Arr::get($fieldOptions, 'label', $fieldName));
         }
     }
     if ($validation->check()) {
         $this->_errors = array();
         return TRUE;
     } else {
         if (!(bool) ($errorMessageFile = $this->_errorMessageFile)) {
             // Konform_Contact => 'konform/contact'
             $errorMessageFile = strtolower(str_replace('_', '/', get_class($this)));
         }
         $this->_errors = $validation->errors($errorMessageFile);
         return FALSE;
     }
 }
开发者ID:drarok,项目名称:konform,代码行数:39,代码来源:Konform.php

示例7: _check

 /**
  * Add validation rules to validation object
  *
  * @param  Validation  Validation object
  * @return array
  */
 protected function _check(Validation $data)
 {
     foreach ($this->_fields as $name => $field) {
         if ($field['type'] === 'email') {
             $data->rule($name, 'email');
         }
         if (Arr::get($field, 'required')) {
             $data->rule($name, 'required');
         }
         if (Arr::get($field, 'unique')) {
             $data->rule($name, array(':model', '_is_unique'), array(':validation', $name));
         }
         foreach (array('min_value', 'max_value', 'min_length', 'max_length') as $rule) {
             if (Arr::get($field, $rule) !== NULL) {
                 $data->rule($name, $rule, array(':value', $field[$rule]));
             }
         }
         if (isset($field['rules'])) {
             $data->rules($name, $field['rules']);
         }
         if (isset($field['label'])) {
             $data->label($name, $field['label']);
         }
     }
     return $data;
 }
开发者ID:tscms,项目名称:mangodb,代码行数:32,代码来源:Mango.php

示例8: onValidateDocument

 /**
  * Правила валидации значения поля документа.
  * При сохранении документа происходит валидация значений его полей. 
  * Каждое поле прогоняется в цикле и происходит вызов этого метода.
  * 
  * @see DataSource_Hybrid_Document::validate()
  * 
  * @param Validation $validation
  * @param DataSource_Hybrid_Document
  * @return \Validation
  */
 public function onValidateDocument(Validation $validation, DataSource_Hybrid_Document $doc)
 {
     if ($this->isreq === TRUE and $this->is_required()) {
         $validation->rule($this->name, 'not_empty');
     }
     if ($this->unique === TRUE) {
         $validation->rule($this->name, array($this, 'check_unique'), array(':value', $doc));
     }
     return $validation->label($this->name, $this->header);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:21,代码来源:field.php

示例9: onValidateDocument

 /**
  * 
  * @param Validation $validation
  * @param DataSource_Hybrid_Document $doc
  * @return Validation
  */
 public function onValidateDocument(Validation $validation, DataSource_Hybrid_Document $doc)
 {
     $image = $doc->get($this->name);
     $url = $doc->get($this->name . '_url');
     $from_url = FALSE;
     if (Valid::url($url)) {
         $from_url = TRUE;
     }
     if ($this->isreq === TRUE and $from_url === FALSE) {
         if (is_array($image)) {
             $validation->rules($this->name, array(array('Upload::not_empty')));
         } else {
             $validation->rules($this->name, array(array('not_empty')));
         }
     } elseif ($this->isreq === TRUE and $from_url === TRUE) {
         $validation->rules($this->name . '_url', array(array('not_empty')));
     }
     if ($from_url === FALSE and is_array($image)) {
         $validation->rules($this->name, array(array('Upload::valid'), array('Upload::type', array(':value', $this->types)), array('Upload::size', array(':value', $this->max_size))));
     } else {
         if ($from_url === TRUE) {
             $ext = strtolower(pathinfo($url, PATHINFO_EXTENSION));
             $validation->rules($this->name . '_url', array(array('url'), array('in_array', array($ext, $this->types))));
         }
     }
     return $validation->label($this->name . '_url', $this->header)->label($this->name, $this->header);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:33,代码来源:image.php


注:本文中的Validation::label方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。