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 6615481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:28:00+00:00 2026-05-25T20:28:00+00:00

I would rather not deal with decorators as my form design is not exactly

  • 0

I would rather not deal with decorators as my form design is not exactly straight forward, but i would like to keep the functionality of validating the forms.

So i have it set up where sub forms are working correctly, but when i try to style it manually in my viewscript i get the name without the parent. I’ve seen other posts that are similar, but i haven’t found a solution.

Example:

This is in my view script

<?php echo $this->form->username->renderViewHelper();?>

I then get

<input type="text" value="" id="username" name="username">

When rendered. It should be

<input type="text" value="" id="form1-username" name="form1[username]">

How do i get that form1 portion?

Thanks!


Edit

Ok, so i found one way.

By using belongTo, it works:

    $form1->addElements(array(
        new Zend_Form_Element_Text('username', array(
            'belongsTo' => 'form1',
            'required'   => true,
            'label'      => 'Username:',
            'filters'    => array('StringTrim', 'StringToLower'),
            'validators' => array(
                'Alnum',
                array('Regex',
                      false,
                      array('/^[a-z][a-z0-9]{2,}$/'))
            )
        ))
     ));

Is there a better way to do this or is this the only way?


Edit2

public function prepareSubForm($spec){
    if (is_string($spec)) {
        $subForm = $this->{$spec};
    } elseif ($spec instanceof Zend_Form_SubForm) {
        $subForm = $spec;
    } else {
        throw new Exception('Invalid argument passed to ' .
                            __FUNCTION__ . '()');
    }
    $this->setSubFormDecorators($subForm)
         ->addSubmitButton($subForm)
         ->addSubFormActions($subForm);
    return $subForm;
}

public function setSubFormDecorators(Zend_Form_SubForm $subForm){
    $subForm->setDecorators(array(
        'FormElements', \\<--- I tried to change this to PrepareElements before.
        array('HtmlTag', array('tag' => 'dl',
                               'class' => 'zend_form')),
        'Form',
    ));
    return $this;
}
  • 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-25T20:28:00+00:00Added an answer on May 25, 2026 at 8:28 pm

    I believe you can get your desired output just by using:

    <?php echo $this->form->username; ?>
    

    I get the expected output when calling this without renderViewHelper. This is also without any special code for decorators or preparing sub forms. All I had to do was add belongsTo to the form element.

    UPDATED:

    If you set this to be your default decorator, you can eliminate the dd/dt tags from rendering, instead it will use a div. Then you may be closer to getting the custom output you want. You can change the tag in HtmlTag from div to whatever tag you would like to wrap your elements in. This is what I use mostly:

    array(
        'ViewHelper',
        'Errors',
        array('Description', array('tag' => 'p', 'class' => 'description')),
        array('HtmlTag', array('tag' => 'div', 'class' => 'form-div')),
        array('Label', array('class' => 'form-label', 'requiredSuffix' => '*'))
    );
    

    This is the default for Zend Framework:

    array(
        'ViewHelper',
        'Errors',
        array('Description', array('tag' => 'p', 'class' => 'description')),
        array('HtmlTag', array('tag' => 'dd', 'id' => array('callback' => $getId)))
        array('Label', array('tag' => 'dt'))
    );
    

    Note that file, and submit/button elements use different decorators.

    Also see this answer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would rather have the DB locally on their server but do not have
Rather than reinvent the wheel I would like to use Outlook to manage my
I would like to ask a rather, general, high-level introductory kind of question regarding
I would like to display a catergory page as my homepage rather than a
I have a rather large diff of 2 GIT branches and would like to
I'd like to add some functionality to a site that would allow users to
Would you rather use a version number (that will increment) or a timestamp to
What would you rather choose to implement deque: HashSet or LinkedList. And could you
I'm trying to do something which I figure would be rather easy, though I'm
Why would one use the AlertDialog.Builder class rather than the methods directly available to

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.