Re: [fw-general] Best way to load Zend_Form_Element_* classes
-- Mark Steudel <[EMAIL PROTECTED]> wrote (on Tuesday, 08 April 2008, 12:17 PM -0700): > I’m just using components of the Zend Framework in my application, and one of > those is Zend_Form which in my header file I’m loading like: > > Zend_Loader::loadClass('Zend_Form'); > > But when I go to instantiate a text element like: > > $usrename = new Zend_Form_Element_Text( ‘username’); > > I got the Class 'Zend_Form_Element_Text' not found error. So I tried loading > the Zend_Form_Element_Text class like so: > > Zend_Loader::loadClass('Zend_Form_Element_Text'); > > My question is do I really need to load each element, I’m figuring there must > be a cleaner way to do load each form element class. Use Zend_Form as a factory for creating elements: $username = $form->createElement('text', 'username'); // or, if you want it attached to the form immediately: $form->addElement('text', 'username'); $username = $form->username; This is actually the preferred way to create elements, as it allows you to set plugin paths for your elements in your form object *once*, and those will then be used for all elements created via your form object. Finally, you might want to use autoloading if you don't want to use Zend_Loader::loadClass() or require_once throughout your code. Add this to the top of your bootstrap or script: require_once 'Zend/Loader.php'; Zend_Loader::registerAutoload(); -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
RE: [fw-general] Best way to load Zend_Form_Element_* classes
Thanks all, that's exactly what I was looking for! Mark _ From: staar2 [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 08, 2008 12:37 PM To: fw-general@lists.zend.com Subject: Re: [fw-general] Best way to load Zend_Form_Element_* classes Mark Steudel-3 wrote: Hi All, I'm just using components of the Zend Framework in my application, and one of those is Zend_Form which in my header file I'm loading like: Zend_Loader::loadClass('Zend_Form'); But when I go to instantiate a text element like: $usrename = new Zend_Form_Element_Text( 'username'); I got the Class 'Zend_Form_Element_Text' not found error. So I tried loading the Zend_Form_Element_Text class like so: Zend_Loader::loadClass('Zend_Form_Element_Text'); My question is do I really need to load each element, I'm figuring there must be a cleaner way to do load each form element class. Thanks, Mark i would write in the index.php file top of the code require_once 'Zend/Loader.php'; Zend_Loader::registerAutoload(); Then you dont need to load each class seperatly _ View this message in context: Re: <http://www.nabble.com/Best-way-to-load-Zend_Form_Element_*-classes-tp165710 99p16571332.html> Best way to load Zend_Form_Element_* classes Sent from the Zend <http://www.nabble.com/Zend-Framework-f15440.html> Framework mailing list archive at Nabble.com.
Re: [fw-general] Best way to load Zend_Form_Element_* classes
Mark Steudel-3 wrote: > > Hi All, > > > > I'm just using components of the Zend Framework in my application, and one > of those is Zend_Form which in my header file I'm loading like: > > > > Zend_Loader::loadClass('Zend_Form'); > > > > But when I go to instantiate a text element like: > > > > $usrename = new Zend_Form_Element_Text( 'username'); > > > > I got the Class 'Zend_Form_Element_Text' not found error. So I tried > loading > the Zend_Form_Element_Text class like so: > > > > Zend_Loader::loadClass('Zend_Form_Element_Text'); > > > > My question is do I really need to load each element, I'm figuring there > must be a cleaner way to do load each form element class. > > > > Thanks, Mark > > > i would write in the index.php file top of the code require_once 'Zend/Loader.php'; Zend_Loader::registerAutoload(); Then you dont need to load each class seperatly -- View this message in context: http://www.nabble.com/Best-way-to-load-Zend_Form_Element_*-classes-tp16571099p16571332.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Best way to load Zend_Form_Element_* classes
Hi All, I'm just using components of the Zend Framework in my application, and one of those is Zend_Form which in my header file I'm loading like: Zend_Loader::loadClass('Zend_Form'); But when I go to instantiate a text element like: $usrename = new Zend_Form_Element_Text( 'username'); I got the Class 'Zend_Form_Element_Text' not found error. So I tried loading the Zend_Form_Element_Text class like so: Zend_Loader::loadClass('Zend_Form_Element_Text'); My question is do I really need to load each element, I'm figuring there must be a cleaner way to do load each form element class. Thanks, Mark