2016-11-07 2 views
0

ändern müssen Standard YII Fehler ZusammengefasstWie YII defualt Fehler Zusammenfassung einzelner Fehler

enter image description here

Um zu zeigen, jeden Fehler insbesondere Formularfeld als Bild unten anpassen.

enter image description here

Hier ist meine worklet Eigenschaften().

public function properties() { 
    return array(
     'action' => url('/user/signup', array('dialog' => isset($_GET['dialog']) ? $_GET['dialog'] : 0)), 
     'elements' => array(
      'firstName' => array('type' => 'text'), 
      'lastName' => array('type' => 'text'), 
      'email' => array('type' => 'text'), 
      'password' => array('type' => 'password'), 
      'passwordRepeat' => array('type' => 'password'), 
      'profile' => wm()->get('user.profile.helper')->form(), 
      '<hr />', 
      'termsAgree' => array(
       'type' => 'checkbox', 
       'layout' => "<fieldset>{input}\n{label}\n{hint}\n{error}</fieldset>", 
       'uncheckValue' => '', 
       'required' => false, 
       'afterLabel' => '', 
      ), 
     ), 
     'buttons' => array(
      'submit' => array('type' => 'submit', 
       'id'=>'signUpButton', 
       'label' => $this->t('Sign Up')), 
     ), 

     'model' => $this->model 
    ); 
} 

Hier ist meine Regeln() für das Modell:

public function rules() 
    { 
     return array(
      array('email, password, passwordRepeat, firstName, lastName', 'required'), 
      array('firstName, lastName, email', 'length', 'max' => 250), 
      array('email', 'email'), 
      array('email', 'unique', 'className' => 'MUser', 'message' => $this->t('This email is already in use.')), 
      array('password', 'length', 'min' => 6), 
      array('passwordRepeat', 'compare', 'compareAttribute'=>'password'), 
      array('termsAgree', 'required', 'message' => $this->t('You must be agree to our Terms of Use and Privacy Policy to join this site.')) 
     ); 
    } 
+0

poste einige code bitte .. wir können dir nicht helfen ohne code – Blueblazer172

+0

schau hier zum offiziellen [docu] (http://www.yiiframework.com/doc-2.0/guide-input-validation.html#validating- Eingabe) – Blueblazer172

+0

Diese Frage ist für Yii1 oder Yii2? – scaisEdge

Antwort

0

Sie

eine Nachricht in Regeln hinzufügen könnte
 array('email, password, passwordRepeat, firstName, lastName', 'required', 
       'message'=>'{attribute} cannot be blank, please enter a value .'), 

Und Sie

sucht Controller
public function actionError() 
{ 
    if($error=Yii::app()->errorHandler->error) 
    {   
    if(Yii::app()->request->isAjaxRequest) { 
    echo $error['message']; 
    } 
    else 
    $this->render('error', $error); 
    } 
} 

und ändern für Sie brauchen

Verwandte Themen