Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7571247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:37:43+00:00 2026-05-30T15:37:43+00:00

I’m looking for a way to wrap zend_form form elements inside div’s. I can

  • 0

I’m looking for a way to wrap zend_form form elements inside div’s.
I can get the desired result by using the code below inside the form class.

                $element->setDecorators(array(
                'ViewHelper',
                'Description',
                'Errors',
                array(array('top-left' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-corner-top-left')),
                array(array('top-right' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-corner-top-right')),
                array(array('top-center' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-top-center')),
                array(array('bottom-left' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-corner-bottom-left')),
                array(array('bottom-right' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-corner-bottom-right')),
                array(array('bottom-center' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-bottom-center')),
                array(array('left' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-left')),
                array(array('right' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-right')),
                array(array('dd' => 'HtmlTag'), array('tag' => 'dd', 'id' => $element->getLabel().'-element')),
                array('Label', array('tag' => 'dt')),
            ));

I would like to know if I could use custom decorators to achieve the desired result.

The code above is very easy to implement but has to be done for every element.
So then I thought, could I use a custom decorator to achieve the same result?

So far I’ve not been able to, which is why I’m asking this question here.

::Edit::

I forgot to mention what I’ve been trying to do so far.
I have been trying to break down the form inside my custom decorator.
But I’ve had no luck so far.

class Form_Decorator_Borders extends Zend_Form_Decorator_Abstract

{

public function render($content)
{
    $element    = $this->getElement();          // get form
    $elements   = $element->getElements();      // get form elements
    $placement  = $this->getPlacement();
    $name       = htmlentities($element->getFullyQualifiedName());
    $id         = htmlentities($element->getId());

    foreach ($elements as $k => $v) {
        if (is_object($v) && get_class($v) == "Zend_Form_Element_Text") {
            $elements[$k]->setDecorators(array(
                'ViewHelper',
                'Description',
                'Errors',
                array(array('top-left' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-corner-top-left')),
                array(array('top-right' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-corner-top-right')),
                array(array('top-center' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-top-center')),
                array(array('bottom-left' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-corner-bottom-left')),
                array(array('bottom-right' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-corner-bottom-right')),
                array(array('bottom-center' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-bottom-center')),
                array(array('left' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-left')),
                array(array('right' => 'HtmlTag'), array('tag' => 'div', 'class' => 'content-border-right')),
                array(array('dd' => 'HtmlTag'), array('tag' => 'dd', 'id' => $elements[$k]->getLabel().'-element')),
                array('Label', array('tag' => 'dt')),
            ));
        }
    }

    $element->setElements($elements);
    $this->setElement($element);

    $this->setElement($element);
    return $this->getElement()->getView()->render($name);
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:37:45+00:00Added an answer on May 30, 2026 at 3:37 pm

    I’ve come to use a different approach.
    This is what I’m currently using and is working fine so far.

    public function render($content)
    {
        $innerHTML = "";
        //Create a new DOM document
        $dom = new DOMDocument;
        $dom->preserveWhiteSpace = false;
    
        //Parse the HTML. The @ is used to suppress any parsing errors
        //that will be thrown if the $html string isn't valid XHTML.
        @$dom->loadHTML($content);
    
        //Get all inputs. You could also use any other tag name here,
        //like 'img' or 'table', to extract other tags.
        $eInputs = $dom->getElementsByTagName('input');
    
        //Iterate over the extracted dds
        foreach ($eInputs as $eInput) {
            if ($eInput->getAttribute('type') == "text") {
                $tmp_doc = new DOMDocument();
                $tmp_doc->appendChild($tmp_doc->importNode($eInput,true));
                $innerHTML .= $tmp_doc->saveHTML()." ";
            } else if ($eInput->getAttribute('type') == "password") {
                $tmp_doc = new DOMDocument();
                $tmp_doc->appendChild($tmp_doc->importNode($eInput,true));
                $innerHTML .= $tmp_doc->saveHTML()." ";
            }
        }
    
        $inputs = explode(" ", $innerHTML);
    
        foreach ($inputs as $input) {
            if (!empty($input)) {
                $input = str_replace(">", " />", $input);
                $input = substr($input, 0, -1);
                $replace = '<div class="content-border-bottom-center">
                    <div class="content-border-top-center">
                        <div class="content-border-corner-bottom-right">
                            <div class="content-border-corner-bottom-left">
                                <div class="content-border-corner-top-right">
                                    <div class="content-border-corner-top-left">
                                        '.$input.'
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>';
                $content = str_replace($input, $replace, $content);
            }
        }
        return $content;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.