Example #1
0
 public function rules()
 {
     return array_merge(parent::rules(), [[['options'], 'required'], [['options'], function ($a, $p) {
         $_ = str_replace("\r", '', $this->{$a});
         $_ = array_map('trim', explode("\n", $_));
         $_ = array_filter($_, function ($v) {
             return !empty($v);
         });
         $out = [];
         foreach ($_ as $v) {
             list($k, $v) = explode('=', $v);
             if (empty($v)) {
                 $v = $k;
             }
             $out[] = trim($k) . '=' . trim($v);
         }
         $this->{$a} = implode("\n", $out);
     }]]);
 }
Example #2
0
 public function rules()
 {
     return array_merge(parent::rules(), [[['maxLen'], 'integer', 'min' => 0]]);
 }