Example #1
0
 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());
 }
Example #2
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());
 }
Example #3
0
 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));
 }
Example #4
0
 function __construct($action)
 {
     parent::__construct('post_form', $action);
     // 输入框
     $props = array('class' => 'textbox', 'max_length' => 85);
     $this->add(new QForm_Element('title', 'textbox', $props))->set('label', '文章标题')->set('description', '');
     $props = array('class' => 'textbox', 'rows' => 20);
     $this->add(new QForm_Element('body', 'memo', $props))->set('label', '文章内容')->set('description', '可以使用 BBCode 格式化内容');
     $props = array('class' => 'textbox', 'max_length' => 60);
     $this->add(new QForm_Element('tags', 'textbox', $props))->set('label', '标签')->set('description', '多个类别间请用空格分隔')->onSetValue(array($this, 'setTags'));
     $props = array('caption' => '保存修改');
     $this->add(new QForm_Element('save', 'submit', $props));
     $this->loadValidationsFromModel('Post');
 }
Example #5
0
 function __construct($id, $action, $method = self::POST, array $attrs = null)
 {
     parent::__construct($id, $action, self::POST, $attrs);
     $this->enctype = self::ENCTYPE_MULTIPART;
 }