예제 #1
0
 /**
  * 从配置文件创建表单
  */
 protected static function _createFromConfig($action, $config_name)
 {
     $form = new Form_Common('form', $action);
     $filename = rtrim(dirname(__FILE__), '/\\') . DS . $config_name . '.yaml.php';
     $form->loadFromConfig(Helper_YAML::loadCached($filename));
     return $form;
 }
예제 #2
0
파일: user.php 프로젝트: Debenson/openwan
 function __construct($action)
 {
     // 调用父类的构造函数
     parent::__construct("form1", $action);
     // 从配置文件载入表单
     $filename = rtrim(dirname(__FILE__), '/\\') . DS . 'user_form.yaml';
     $this->loadFromConfig(Helper_YAML::loadCached($filename));
     // 添加表单验证
     //$this->addValidations(Users::meta());
 }
예제 #3
0
 function __construct($action)
 {
     // 调用父类的构造函数
     parent::__construct("form_changepassword", $action);
     // 从配置文件载入表单
     $filename = rtrim(dirname(__FILE__), '/\\') . DS . 'changepassword_form.yaml';
     $this->loadFromConfig(Helper_YAML::loadCached($filename));
     $this['old_password']->addValidations(array($this, 'checkPasswordLen'), '密码长度只能在4-32位之间');
     $this['new_password']->addValidations(array($this, 'checkPasswordLen'), '密码长度只能在4-32位之间');
     $this['new_password2']->addValidations(array($this, 'checkSecPasswd'), '两次输入的密码必须一致');
     //$this->addValidations(Users::meta());
 }
예제 #4
0
파일: base.php 프로젝트: Debenson/openwan
 function __construct($config_name = 'default', $udi = null, $model = null, $has_file = null, $must = false)
 {
     parent::__construct('form_' . $config_name, url($udi), 'post');
     if ($has_file) {
         $this->enctype = self::ENCTYPE_MULTIPART;
         $this->has_file = $has_file;
         $this->must = $must;
     }
     $file_name = $config_name . '_form.yaml';
     $filename = rtrim(dirname(__FILE__), '/\\') . DS . $file_name;
     $this->loadFromConfig(Helper_YAML::loadCached($filename));
     $this->addValidations(QDB_ActiveRecord_Meta::instance($model));
 }
예제 #5
0
파일: form.php 프로젝트: xyz12810/xiao3vpn
 /**
  * 从一个 YAML 文件载入表单设置和元素
  *
  * @param string $filename 要载入的配置文件
  * @param bollean $cached 是否缓存配置文件
  *
  * @return QForm 返回表单对象本身,实现连贯接口
  */
 function loadFromConfigFile($filename, $cached = true)
 {
     if ($cached) {
         $config = Helper_YAML::loadCached($filename);
     } else {
         $config = Helper_YAML::load($filename);
     }
     return $this->loadFromConfig($config);
 }