SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zend_Form_Element_File with viewscript errors

    I'm trying to use a custom viewscript to handle a form but I'm running into trouble with Zend_Form_Element_File::hasErrors(). The viewscript block below works fine for text fields and textareas but not with files. I'm using Zend Framework Version: 1.9.0. Has anyone encountered this specific problem?

    The form field creation
    PHP Code:
            $fields['pa_img'] = $this->createElement('file''pa_img', array('label' => 'Image'))
                                     ->
    setDestinationrealpath(APPLICATION_PATH '/../httpdocs/media') )
                                     ->
    clearDecorators()
                                     ->
    addDecorator('File')
                                     ->
    addDecorator('Errors')
                                     ->
    setRequired(true)
                                     ->
    addErrorMessage($message); 
    Rendering the element block...
    PHP Code:
    <?php $element $this->element?>
                    <div class="span-12 last">
                        <?= $this->formLabel($element->getName(),
                                             
    $element->getLabel()) ?>

                    </div>
                    <div class="span-12 last">
    <?php
        $attribs 
    $element->getAttribs();
        unset(
    $attribs['helper']);
    ?>
                        <?= $this->{$element->helper}(
                                
    $element->getName(),
                                
    $element->getValue(),
                                
    $attribs?>

                    </div>
    <?php if( $element->hasErrors() ): ?>
                    <div class="span-12 last bold">
                        <div class="errors">
                        <?= current($element->getMessages()); ?>

                        </div>
                    </div>
    <?php endif; ?>
                    <hr class="space" />
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can anyone tell me why Zend_Form_Element_File doesn't call Zend_Form_Element::markAsError in Zend_Form_Element_File::isValid? Am I missing something? All other elements call markAsError so I don't exactly why it doesn't...
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually never mind... I read something wrong -.-
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  4. #4
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yay! Customized error messages don't work with Zend_Form_Element_File what a fail -.-...
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •