开发者

Can you add an error decorator to a Zend subform?

开发者 https://www.devze.com 2023-01-22 19:41 出处:网络
I have a custom validator that checks all the values in a subform to make sure that they make sense in relation to each other.In the event that this validator fails, I\'d like to have an error decorat

I have a custom validator that checks all the values in a subform to make sure that they make sense in relation to each other. In the event that this validator fails, I'd like to have an error decorator at the top of the subform to display the error message. Is this possible?

I've already set up the decorators like so:

protected $_decorators = array( 
    array(
        'decorator' => 'FormElements',
        'options' => array()
    ),
    array(
        'decorator' => 'HtmlTag', 
        'options' => array(
            'tag' => 'ul',
            'class' => 'test'
        )
    ),  
);

And it seems like I should be able to add

array(
    'decorator' => 'Errors', 
    'options' => array(
        'tag' => 'ul',
        'class' => 'errors',
        'placement' => 'prepend开发者_StackOverflow社区',
    )
),

but that causes Zend to fail with the error "htmlspecialchars() expects parameter 1 to be string, array given". What am I doing wrong then? Thanks!


I believe nothing is wrong in your code, just ZF doesn't handle the Errors decorator within Zend_Form_SubForm properly. I hope they will fix this soon.

0

精彩评论

暂无评论...
验证码 换一张
取 消