Bonjour,
J'aimerai utiliser cette magnifique bibliothèque qu'est JQuery, je me casse la tête depuis toute l'aprèm et je n'arrive à rien, alors je me tourne vers vous.
Je souhaite faire marcher une date à l'aide de datePicker. Mais ça ne marche pas. J'aimerai avoir vos lumières.
J'ai donc l'arborescence suivante :
Citation:
/application
/img
/library
--> Zend
--> ZendX
/public
-->js -->jquery
Voici le formulaire que je souhaite afficher :
/application/modules/defaut/forms/Profil.php
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 <?php class Default_Form_Profil extends ZendX_JQuery_Form { public function init() { $this->setName('rubrique'); $dateNaiss = new ZendX_JQuery_Form_Element_DatePicker( 'dateNaiss', array('label' => 'Date de naissance (jj/mm/aaaa)') ); $dateNaiss->setJQueryParam('dateFormat', 'dd/mm/yyyy'); $signature = new Zend_Form_Element_Textarea('signature'); $signature->setLabel('Signature') ->addFilter('StripTags') ->addFilter('StringTrim'); $mail = new Zend_Form_Element_Text('mail'); $mail->setLabel('E-mail') ->addFilter('StripTags') ->addFilter('StringTrim') ->addValidator('EmailAddress'); $envoyer = new Zend_Form_Element_Submit('valider'); //$envoyer->setAttrib('id', 'boutonenvoyer'); $this->addElements(array($login, $avatar, $pseudo, $sexe, $dateNaiss, $signature, $mail, $envoyer)); } }
Mon contrôleur : /application/modules/defaut/controllers/ProfilController.php
ma vue /application/modules/defaut/views/scripts/Profil/index.phtmlCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94 <?php class ProfilController extends Zend_Controller_Action { public function init() { parent::init(); $models = $this->_request->getParam('module').'/models'; set_include_path('../application/modules/'.$models . PATH_SEPARATOR . get_include_path()); $this->view->module = $this->getRequest()->getModuleName(); // recupere le module $this->view->controller = $this->getRequest()->getControllerName(); // recupere le controller $this->view->action = $this->getRequest()->getActionName(); // recupere l'action // Gère la session $this->view->auth = new Zend_Session_Namespace('user'); // si pas connecté, on redirige if(!isset($this->view->auth->login)) { $this->_redirect('/'); } } public function indexAction() { $this->view->title = "profil"; $this->view->headTitle($this->view->title, 'PREPEND'); $form = new Default_Form_Profil(); $this->view->form = $form; $this->view->jQuery()->enable()->uiEnable(); $user = new Default_Models_DbTable_Users(); $user = $user->searchUser($this->view->auth->login); $this->view->avatar = ''; if(!empty($user["avatar"])) $this->view->avatar = './data/img/avatars/'.$user["avatar"]; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $login = $form->getValue('login'); $pseudo = $form->getValue('pseudo'); $dateNaiss = $form->getValue('dateNaiss'); $signature = $form->getValue('signature'); $sexe = $form->getValue('sexe'); $mail = $form->getValue('mail'); $avatar = $form->getValue('avatar'); $values = array( 'pseudo'=>$pseudo, 'dateNaiss'=>$dateNaiss, 'signature'=>$signature, 'avatar'=>$avatar, 'sexe'=>$sexe, 'mail'=>$mail ); if (!$form->avatar->receive()) { echo "Erreur d'upload"; } try { $user = new Default_Models_DbTable_Users(); $user->updateUser($login, $values); }catch (Exception $e) { echo $e->getMessage(); } $this->_redirect('/profil'); } else { $form->populate($formData); } } else { try { $user = new Default_Models_DbTable_Users(); $form->populate( $user->searchUser($this->view->auth->login) ); } catch (Exception $e) { echo $e->getMessage(); $this->view->form = null; } } } }
Mon Bootstrap : /application/Bootstrap.phpCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 <article> <h2>Profil - <?php echo $this->auth->login; ?></h2> <?php $this->jQuery()->enable(); ?> <?php echo $this->datePicker('dateNaiss', '30-07-2010', array('dateFormat' => 'dd-mm-yy', 'changeMonth' => true, 'changeYear' => true), array()) ?> <?php if(!empty($this->avatar)) { ?> <img src="<?php echo $this->avatar;?>" alt="avatar de <?php echo $this->auth->login; ?>" class="avatar" /> <?php } ?> <?php echo $this->form; ?> </article>
et enfin, le layout :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 <?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initAutoLoader() { $autoloader = Zend_Loader_Autoloader::getInstance(); //on configure le module par défaut avec son namespace, son chemin et les ressources associées $moduleLoader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Default_', 'basePath' => APPLICATION_PATH . '/modules/default')); $moduleLoader->addResourceType('Models', 'models', 'Models'); $moduleLoader->addResourceType('Forms', 'forms', 'Forms'); Zend_Session::start(); return $moduleLoader; } /** * Fonction servant Ã* initialiser la vue */ protected function _initView() { // Initialize view $view = new Zend_View(); $view->doctype('HTML5'); $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8'); $view->headTitle()->setSeparator(' - '); $view->headTitle(' Site du Tutorat'); return $view; } /** * Initialize Translation * * @return Zend_Translate */ public function _initTranslate() { $translate = new Zend_Translate('array', APPLICATION_PATH . '/languages/fr.php', 'fr'); Zend_Registry::set('Zend_Translate', $translate); return $translate; } //ne marche pas ! /*protected function _initJQuery() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper'); }*/ }
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 <?php echo $this->doctype(); ?> <html lang="fr"> <head> <?php echo $this->headTitle(); ?> <?php echo $this->headMeta(); ?> <?php echo $this->headLink()->prependStylesheet($this->baseUrl().'/themes/default/base.css'); ?> <?php echo $this->headScript()->appendFile($this->baseUrl().'/javascript/javascript.js', 'text/javascript'); ?> </head> <body> <section id="page"> <?php echo $this->partial('header.phtml', array('menu'=>$this->menu($this->baseUrl()))); ?> <section id="content"> <?php echo $this->partial('filAriane.phtml', array('filAriane'=>$this->filAriane($this->baseUrl(), $this->module, $this->controller, $this->action, $this->page))); echo $this->partial('sideMenu.phtml', array('module'=>$this->module)); ?> <section> <?php //cette fonction permet de récupérer la vue de l'action appelée echo $this->layout()->content; ?> </section> </section> <?php echo $this->partial('footer.phtml'); ?> </section> </body> </html>
Merci s'il est possible d'avoir une aide.
Concrètement, il ne se passe rien. Dans le meilleur des cas, le formulaire apparaît, mais lorsque je clique sur le champs, rien n’apparaît.