Add class attribute to Form Errors

后端 未结 6 2019
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 09:15

I´m developing an application using Zend Framework 2 and I use FormRow helper to render a label, the input and errors (if present) in a Form.



        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 09:30

    Ok, the solution to my own problem was right in front of me, instead of using:

    //within the view
    echo $this->formRow($form->get('Name'));
    

    I called each element of the form individually:

        //within the view
        echo $this->formLabel($form->get('Name'));
        echo $this->formInput($form->get('Name'));
        echo $this->formElementErrors($form->get("Name"), array('class' => "some_class", 'message' => "errormessage")); 
    

    Don´t know if it´s the most efficient way of doing it, plz drop a line if you think otherwise.

提交回复
热议问题