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


PHP ActiveRecord::isValid方法代码示例

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


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

示例1: isValid

 function isValid()
 {
     $valid = true;
     if (!$this->getData('company_id')) {
         $this->errors[] = 'company_id must be set.';
         $valid = false;
     }
     if (!$this->getData('amount_due')) {
         if (!$this->getData('start_date')) {
             $this->errors[] = 'start_date must be set.';
             $valid = false;
         }
         if (!$this->getData('end_date')) {
             $this->errors[] = 'end_date must be set.';
         }
     }
     if ($valid && parent::isValid()) {
         return true;
     }
 }
开发者ID:radicaldesigns,项目名称:gtd,代码行数:20,代码来源:Invoice.php

示例2: error_messages_for

 /**
  * Finds and retuns a HTML formatted string with errors for an ActiveRecord object
  *
  * Eg.
  * <code>
  *  <?=ActiveRecordHelper::error_messages_for($person);?>
  * </code>
  * will show all the errors for the person object.
  *
  * Valid options:
  * <ul>
  *  <li>css_class [ default formErrors ] for: &lt;div id="" class="$css_class"&gt;</li>
  *  <li>heading   [ default 2 1-->6    ] for: &lt;h$heading&gt;&lt2 errors prohibited this form from beeing saved;/h$heading&gt;
  *  <li>singular  [ default error      ] for: 1 $singular prohibited this...</li>
  *  <li>plural    [ default errors     ] for: 2 $plural prohibited this...</li>
  *  <li>oname     [ default object name] for: the active record object name</li>
  * </ul>
  * 
  * @param ActiveRecord object the ActiveRecord object to check for errors
  * @param array options the options where we can cusomize the look and feel of the error message.
  *                      this includes: css_class and heading
  * @return string a HTML formatted string
  */
 public static function error_messages_for(ActiveRecord $record, $options = array())
 {
     if ($record->isValid()) {
         return;
     }
     $css_class = isset($options['css_class']) ? $options['css_class'] : 'formErrors';
     $heading = isset($options['heading']) && (int) $options['heading'] > 0 && (int) $options['heading'] < 6 ? $options['heading'] : 2;
     $singular = isset($options['singular']) ? $options['singular'] : 'error';
     $plural = isset($options['plural']) ? $options['plural'] : 'errors';
     $oname = isset($options['oname']) ? $options['oname'] : ucfirst($record->getClassName());
     $buffer = '<div id="medickFormErrors" class="' . $css_class . '">';
     $part = '<ul>';
     foreach ($record->getErrors() as $error) {
         $part .= '<li>' . $error . '</li>';
     }
     $part .= '</ul>';
     $st = sizeof($record->getErrors()) == 1 ? $singular : $plural;
     $buffer .= '<h' . $heading . '>' . sizeof($record->getErrors()) . ' ' . $st . ' prohibited this ';
     $buffer .= $oname . ' from being saved</h' . $heading . '>';
     $buffer .= "\n<p>There were problems with the following fields:</p>\n";
     $buffer .= $part;
     return $buffer . '</div>';
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:46,代码来源:HTML.php

示例3: isValid

 function isValid()
 {
     $valid = true;
     if (!Util::is_a_date($this->get('start_date'))) {
         $this->errors[] = 'Contract ' . $this->id . ' has no start date.';
         $valid = false;
     }
     if ($valid && parent::isValid()) {
         return true;
     }
 }
开发者ID:radicaldesigns,项目名称:gtd,代码行数:11,代码来源:SupportContract.php


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