Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-26-2008, 10:39 PM
Junior Member
 
Join Date: Mar 2008
Posts: 1
Question 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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-23-2008, 02:49 PM
Junior Member
 
Join Date: Apr 2008
Posts: 1
Default

I am pretty much in the same situation. No idea how to edit the forms using decorators and such.

Also seems to be no way of changing the size of a textarea when using Zend_Form_Element_Textarea where as using Zend_Form->addElement you can add rows and cols in the options array.

EDIT: Actually you can change the size of the textarea by adding
Code:
->setAttrib('rows','10')
->setAttrib('cols','50')
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:44 PM.