0
votes

I am trying to add jQuery datepicker with Zend_Form. But it's giving two warnings and one error. My sample code:

$startdate = new ZendX_JQuery_Form_Element_DatePicker( 'startdate' );
$startdate->setLabel('Start Date')
          ->setRequired(true)
          ->setAttrib('size', '10')
          ->setDecorators($formJQueryElements);

Errors: Warning: include_once(ZendX/JQuery/Form/Element/DatePicker.php) [function.include-once]: failed to open stream: No such file or directory in /usr/local/ZendFramework/library/Zend/Loader.php on line 146


Warning: include_once() [function.include]: Failed opening 'ZendX/JQuery/Form/Element/DatePicker.php' for inclusion (include_path='/opt/lampp/htdocs/framework/students/application/../library:/opt/lampp/htdocs/framework/students/library:include_path = .:/usr/share/php:/usr/local/ZendFramework/library') in /usr/local/ZendFramework/library/Zend/Loader.php on line 146


Fatal error: Class 'ZendX_JQuery_Form_Element_DatePicker' not found in /opt/lampp/htdocs/framework/students/application/forms/Student.php on line 46

3
Can you post the code where you are including/ autoloading the ZendX library? Perhaps in your Bootstrap.php? - James

3 Answers

4
votes

ZendX is an extras library that is not included in all distributions of Zend Framework. Make sure you have downloaded from the Zend Framework Download Page one of the distributions with full in the title.

After you extract the compressed files you will find the ZendX library in the folder extras/library/ZendX copy the ZendX folder to wherever you keep your current Zend folder (not in the Zend folder),

In my case I keep my Zend Framework Library at: C:\Zend\ZendServer\share\ZendFramework\library. So I would have 2 folders at this location Zend and ZendX.

Zend and ZendX both have default namespaces in the autoloader so if you store them in the same place, if one works the other will work.

Or... Put both in your application library like:

/application
/library
    /Zend
    /ZendX

This will work as well.

1
votes

Is there some particular reason you're using ZendX_JQuery_Form_Element_DatePicker? I'm using the jquery datepicker (from the jquery ui package) with a normal Zend Form Text element like this..

    // Add start_date element
    $start_date = new Zend_Form_Element_Text('start_date'); 
    $start_date->setLabel('Start Date')
          ->setRequired(true)
          ->setAttrib('class', 'datepicker')
          ->setDecorators($this->elementDecorators);
    $this->addElement($start_date);  

Adding the 'datepicker' class is all that's really required. This sidesteps the issue you are experiencing - which seems to be related to the use of the ZendX library.

0
votes

I don't know more about Zend framework, However, Zend Framework is Server side technology meant by PHP and Jquery is Client side Technology. In other word there is no direct relation between Jquery date picker working and Zend Framework.

You have to check the HTML output of your page including the form element that works with date picker and the Javascript include files in your page. just look to the page source in your browser, search for something missing.