Exemplo n.º 1
0
 /**
  * Defines an attribute.
  * @param string $name the attribute name
  * @param mixed $value the attribute value
  * @param string $label the attribute label
  */
 public function defineAttribute($name, $value = null, $label = null)
 {
     if ($label) {
         $this->_attributeLabels[$name] = $label;
     }
     parent::defineAttribute($name, $value);
 }
Exemplo n.º 2
0
 private function buildModel($fb, $data)
 {
     $model = new DynamicModel();
     for ($i = 0; $i < count($fb->fieldName); $i++) {
         $name = 'f' . $i;
         $model->defineAttribute($name, $data[$name]);
         if ($fb->fieldRequired[$i]) {
             $model->addRule($name, 'required', ['message' => 'Необходимо заполнить поле "' . $fb->fieldName[$i] . '"']);
         } else {
             $model->addRule($name, 'safe');
         }
     }
     if ($fb->useCaptcha) {
         $model->defineAttribute('captcha', $data['captcha']);
         $model->addRule('captcha', 'captcha');
     }
     return $model;
 }