DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        How can I use zend form decorator to render errors inside my paragraph tag wrapping label and input

        1.8k Views Asked by Fino At 31 October 2011 at 22:09 2025-12-19T23:30:10.889839

        I would like to render the following markup:

        <div class="row">
        <p>
          <label>Your Name</label>
          <input type="text" class="text_field" name="name">
          <ul class="errors">
            <li>Waarde is vereist en kan niet leeg worden gelaten</li>
          </ul>  
        </p>
        </div>
        

        This is my Zend form element + decorator:

        $this->addElement('text', 'name', array(        
                    'label' => 'Naam:',
                    'class' => 'text_field',
                    'required' => true,
                    'decorators' => array(
                        'ViewHelper',
                        'Label',
                        'Errors',
                        array(array('row' => 'HtmlTag'), array('tag' => 'p')),
                        array(array('content' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row'))
                    )));
        

        But this always renders the ul list below the p tag and never inside. It also adds an additional p tag below the list.

        <div class="row">
          <p>
            <label class="required" for="name">Naam:</label>
            <input type="text" class="text_field" value="" id="name" name="name">
          </p>
          <ul class="errors">
            <li>Waarde is vereist en kan niet leeg worden gelaten</li>
          </ul>
          <p></p>
        </div>
        

        What am I doing wrong?

        zend-framework zend-form zend-decorators
        Original Q&A
        2

        There are 2 best solutions below

        0
        Fino Fino On 01 November 2011 at 21:03 BEST ANSWER

        Found it! My stupid mistake. I did only check the final rendered output in my browser. I am using a template which also loads javascript and this changes the DOM which creates the unwanted result.

        So the first decorator setup was working correct.

        1
        Fatalist Fatalist On 01 November 2011 at 15:20

        Try to do the following:

        $this->addElement('text', 'name', array(        
                    'label' => 'Naam:',
                    'class' => 'text_field',
                    'required' => true,
                    'decorators' => array(
                        'ViewHelper',
                        'Label',
                        'Errors',
                        array(array('content' => 'HtmlTag'), array('tag' => 'p')),
                        array(array('content' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row'))
                    )));
        

        Related Questions in ZEND-FRAMEWORK

        • How to properly quote / escape this INSERT statement in Zend 1 Framework
        • Zend Barcode label distance ajustment
        • cast in doctrine query builder
        • Laminas $filter->getValues() in getData() of laminas-form return duplicate of array collection when using Element File
        • I want to translate country name to english in using diffrent country locale Magento2?
        • How to get the name of the module, controller and action in Laminas framework?
        • Zend XmlRpc Client gzinflate out of memory on php 7.1
        • Zend Barcode image isn't generate correctly in CodeIgniter
        • How to switch between the read-only and read-write db conenctions in Laminas using DBAL
        • Database transaction is not working as expected even rollback is not working
        • Ajax call in Zend 1.12 return 404
        • Zend Framework 1 legacy application redesign
        • Zend Barcode image do not generate correcly
        • How to click the button after displaying the dialog box in jquery
        • Zend Session Error, Session must be started before any output has been sent to browser

        Related Questions in ZEND-FORM

        • Zend Session Error, Session must be started before any output has been sent to browser
        • How to use OptionalInputFilter and ways to validate it
        • How can I use javascript form validation alongside ZF1 form validation?
        • Laminas / Zf3 - Accessing form parameters from Fieldset
        • This result is a forward only result set, calling rewind() after moving forward is not supported
        • PHPUnit testing a Laminas form with custom validator with dependencies
        • Keep old value of a select field in a form - Zend Framework 2
        • Populate Multi select drop drop down zend 3
        • Zend 1 radio option as image
        • How to add an error message based on two field values using Zend_Validate_Db_NoRecordExists
        • Problem with binding an object in the form with Zend Framework
        • how to remove fields from form class and view
        • Try to change database name in zend
        • How to fix 'The input was not found in the haystack' in ZF2?
        • Zend framework 3 form issue with binding entities that use return type hinting

        Related Questions in ZEND-DECORATORS

        • Difficult decorators for file input
        • Zend Form Decorators for theme
        • Decorators Zend Framework PHP
        • Zend1 - form radio decorators
        • Multiple Zend 1 From elements in single row
        • How to render Foundation 5's wrapper divs around form elements using Zend Framework
        • Zend Form Decorators add classes
        • Zend decorator - Add css class on field element?
        • Zend_Form_decorator custom class to input
        • How do I allow html tags in label for Zend form element using addElement()?
        • Form's element filter doesnt work
        • Label tag for text input element
        • How to render input inside label - using zend form
        • How to decorate radio options in zend framework?
        • Custom Decorator Label in Zend Framework 2

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Pricesm.com
        • Aftereffectstemplates
        • Jogjafile