Zend Form Decorator Help Needed
Hello everybody!
So I recently took on an entry-level job as a web guy, and what I'm being asked to do seems far from entry level. My task is to learn everything there is to know about the Zend Framework and use it to make a pretty lame interface for administering a website.
The problem: Learning the Zend Framework is pretty much my crash-course introduction to object oriented programming, so a lot of important details are missed when I RTFM because of my lack of basic understanding. The zend reference manual seems to make more sense when you aren't using the MVC model, but I am. (trying at least)
I have created a class for a form, which allows people to edit the homepage of this website. Below is my form class.
class EditHomepageForm extends Zend_Form
{
public function __construct($options = NULL)
{
parent::__construct($options);
$this->setName('homepage');
$headline = new Zend_Form_Element_Text('form_headline');
$headline->setLabel('Page Headline')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$bodyText = new Zend_Form_Element_Textarea('form_bodyText');
$bodyText->setLabel('Body Text')
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$submit = new Zend_Form_Element_Submit('form_submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($headline, $bodyText, $submit));
}
}
Then there is the part of my Controller where I assign the form to a variable for use in my View:
$form = new EditHomepageForm();
$form->setLabel('DeezNutz');
$this->view->form = $form;
And then I am simply echoing the form on my view script.
Seems pretty standard issue and I understand what's happening so far. But when the form outputs, it has all these garbage tags in the HTML. What i'm having trouble with is understanding the methods and properties associated with decorators and just how to change the layout of my form in general. What I think i want to do is create a custom decorator and simply tell my form to use it. I have read the manual a million times and like I said, i'm not a pro. Can somebody just re-post my code with the necessary changes (including some info about where i should put my new decorator classes and how to reference them) and then i should be able to figure out how to make the actual decorator from the documentation. Sorry I suck at this but you gotta start somewhere!
|