views:

202

answers:

2

I am just starting out with the Zend Framework and I am a little confused but getting there. Anyway I have been reading the documentation for *Zend_Form* and was wondering about setting values for the form such as this:

$form->setAction('')
->setMethod('post')

setAction and setMethod were the only two options given and I was wondering if there was a list anywhere of what I can and can't use. I tried to set the ID with setId and that didn't work.

I know that I can set it this way
$form->setAttrib('id', 'login');

Is this the only way to set an ID for the form? AKA what other options can I set right off the bat without using a setAttrib?

Thanks, Levi

+3  A: 

Check out the API docs on Zend site for all the methods available out-of-the-box:

There is no setId method (though there is a getId), but you could create a subclass of Zend_Form:

class My_Form extends Zend_Form
{
    public function setId($id)
    {
        $this->setAttrib('id', $id);
    }
}

Also, you might use Zend_Form's setConfig method to configure the form from an .ini file:

Typeoneerror
A: 

The Zend_Form package was designed with HTML Forms in mind, which means that for form elements, control names are required. To keep consistency across the package, "name" is your primary identifier.

The standard helper for Zend_Form objects (Zend_Form_Decorator_Form) adds an 'id' attribute to the list of attributes for the form (using the getId() method). The default value for getId() is, ultimately, the return value of the getName(), unless setAttrib('id', $id) was used previously.

So... Simple answer is, use the setName($name) method of Zend_Form, and your id attribute will be set to the same.

J. Kenzal Hunter Sr.