在IndexController中创建表单不起作用

时间:2019-02-09 11:20:39

标签: php zend-framework3

我是ZF3的新手,请遵循并使用教程

  

https://olegkrivtsov.github.io

我在名称空间Application \ Form中定义了一个新类AddUser。

onSubmit() {
  this.submitted = true;
  if (this.loginForm.invalid) {
    return;
  }
  const user = {
    email: this.loginForm.controls.email.value,
    password: this.loginForm.controls.password.value,
  };
  this.auth.loginUser(user);
  this.auth.isUserLoggedIn.subscribe((val) => {
    // this.loggedIn = val.valueOf();
    this.loggedIn = val;
    // console.log(this.loggedIn);
    this.route.navigate(['/dashboard']);
  });
  this.loginError = this.auth.loginErr;
  console.log(this.loginError);
}

我写了一个serviceAction()方法来显示表单

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { BehaviorSubject } from 'rxjs';
import { Observable} from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class AuthService {

  checkStatus = new BehaviorSubject<boolean>(false);
  isUserLoggedIn = this.checkStatus.asObservable();
  loginErr: boolean=false;
  readonly loginUrl= 'http://****************';

   checkLogin() {
    const token = localStorage.getItem('access_token');
    if(token) {
      this.checkStatus.next(true);
    } else {
      this.checkStatus.next(false);
    }
  }

  loginUser(user: any) {
    return this.http.post(this.loginUrl, user)
    .subscribe((res: any) => {
        localStorage.setItem('access_token', res.success.token);
        // localStorage.setItem('user', JSON.stringify(success.success.token));
        this.checkLogin();     
    },
    (err) => {
      if(err.error.error){ this.loginErr = true; 
      // console.log(this.loginErr) 
    }
    }); 
  }
}

浏览器仅显示一个错误:

  

警告:“继续”定位开关等效于“中断”。你是否   是要使用“继续2”?在   /home/alba2/domains/alba2.ayz.pl/private_html/primus/vendor/zendframework/zend-stdlib/src/ArrayObject.php   在第428行

     

致命错误:Zend \ Form \ Form :: bindValues(array $ values =   数组)必须与Zend \ Form \ Fieldset :: bindValues(array   $ values = Array,?array $ validationGroup = NULL)在   /home/alba2/domains/alba2.ayz.pl/private_html/primus/vendor/zendframework/zend-form/src/Form.php   在第24行

0 个答案:

没有答案