somejkuser
somejkuser

Reputation: 9040

Zend Custom ViewScript for Form not rendering file element

I created a custom viewscript for a zend form. In the form, there is a file element. When I run the code echo $this->element->elementname->renderViewHelper() it works fine on all elements except the file element. When I run the following code on my file element within my custom viewscript, i get the following error: Uncaught exception 'Zend_Form_Element_Exception' with message 'Decorator by name ViewHelper does not exist'

<?php if($this->element->avatarimage->hasErrors()):?>
        <div class="control-group error">
    <?php else: ?>
        <div class="control-group">
    <?php endif;?>
        <label for="avatarimage" class="control-label">Avatar Image</label>
        <div class="controls">
            <?php echo $this->element->avatarimage->renderViewHelper();?>
            <?php if($this->element->avatarimage->hasErrors()):
                    $messages = $this->element->avatarimage->getMessages();
                    $messages = array_values($messages);
                    $message  = $messages[0];
                    echo '<span class="help-inline">'.$message.'</span>';
                endif;
            ?>              
        </div>
    </div>

How can I incorporate my file element into my custom form viewscript?

Upvotes: 0

Views: 1035

Answers (2)

naquiuddin
naquiuddin

Reputation: 1000

This should definitely work.

<? echo $this->element->avatarimage->renderFile(); ?>

Upvotes: 3

dimirc
dimirc

Reputation: 6605

Try like this:

<?php echo $this->element->avatarimage;?>

Upvotes: 0

Related Questions