Bonjour,

J'ai un formulaire constitué de trois listes déroulantes et de deux datefield un pour une date de début et l'autre pour une date de fin.

Je voudrais que dans la date de début en valeur par défaut soit le premier jour du mois et en fin le dernier. J'ai essayé de remplir l'attribut 'value' ça marche pour un mais si j'en mets deux --> erreur.

J'ai repris l'exemple d'extJS sur les vtype.

Voici le code de ma partie formulaire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
	//on créer le formulaire
	echo "<script type='text/javascript'>
	/*!
	 * Ext JS Library 3.1.1
	 * Copyright(c) 2006-2010 Ext JS, LLC
	 * licensing@extjs.com
	 * http://www.extjs.com/license
	 */
 
	// Add the additional 'advanced' VTypes
	Ext.apply(Ext.form.VTypes, {
    daterange : function(val, field) {
        var date = field.parseDate(val);
 
        if(!date){
            return false;
        }
        if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
            var start = Ext.getCmp(field.startDateField);
            start.setMaxValue(date);
            start.validate();
            this.dateRangeMax = date;
        }
        else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
            var end = Ext.getCmp(field.endDateField);
            end.setMinValue(date);
            end.validate();
            this.dateRangeMin = date;
        }
        /*
         * Always return true since we're only using this vtype to set the
         * min/max allowed values (these are tested for after the vtype test)
         */
        return true;
    }
	});
 
	Ext.onReady(function()
		{
		/**
		 * Handler specified for the 'Available' column renderer
		 * @param {Object} value
		 */
 
		function formatDate(value)
			{
			return value ? value.dateFormat('M d, Y') : '';
			}
 
		// shorthand alias
		var fm = Ext.form;
 
		//create Data Store for ComboBox and create ComboBox
		var storeProject = new Ext.data.Store({
			// destroy the store if the grid is destroyed
			autoDestroy: true,
			autoLoad: true,
			// load remote data using HTTP
			url: './includes/project_RptPj.php',
 
			// specify a XmlReader (coincides with the XML Ext.format of the returned data)
			reader: new Ext.data.XmlReader({
				// records will have a 'project' tag
				record: 'project',
				// use an Array of field definition objects to implicitly create a Record constructor
				fields: [
					{name: 'projectId'},
					{name: 'projectName'}					
					]
				}),
			sortInfo: {field:'projectId', direction:'ASC'}
			});
 
		var storeDiscipline = new Ext.data.Store({
			// destroy the store if the grid is destroyed
			autoDestroy: true,
			autoLoad: false,
			// load remote data using HTTP
			url: './includes/discipline_RptPj.php',
 
			// specify a XmlReader (coincides with the XML Ext.format of the returned data)
			reader: new Ext.data.XmlReader({
				// records will have a 'discipline' tag
				record: 'discipline',
				// use an Array of field definition objects to implicitly create a Record constructor
				fields: [
					{name: 'disciplineId'},
					{name: 'disciplineName'}					
				]
			}),
			sortInfo: {field:'disciplineId', direction:'ASC'}
			});			
 
		var storeSociete = new Ext.data.Store({
			// destroy the store if the grid is destroyed
			autoDestroy: true,
			autoLoad: false,
			// load remote data using HTTP
			url: './includes/societe_RptPj.php',
 
			// specify a XmlReader (coincides with the XML Ext.format of the returned data)
			reader: new Ext.data.XmlReader({
				// records will have a 'societe' tag
				record: 'societe',
				// use an Array of field definition objects to implicitly create a Record constructor
				fields: [
					{name: 'societeId'},
					{name: 'societeName'}					
				]
			}),
			sortInfo: {field:'societeId', direction:'ASC'}
			});				
 
		var comboSociete = new Ext.form.ComboBox({
			allowBlank: false,
			lazyRender: true,
			maxLength: 55,
			width: 110,			
			editable: false,
			emptyText: 'Select a company',	
			mode: 'local',
			triggerAction: 'all',
			store: storeSociete,
			valueField: 'societeId',
			displayField: 'societeId',
			fieldLabel: 'Company ',
			name: 'selectSte'	
			});
 
		var comboDiscipline = new Ext.form.ComboBox({
			allowBlank: false,
			lazyRender: true,
			maxLength: 55,
			width: 110,			
			editable: false,
			emptyText: 'Select a discipline',	
			mode: 'local',
			triggerAction: 'all',
			store: storeDiscipline,
			valueField: 'disciplineId',
			displayField: 'disciplineId',
			fieldLabel: 'Discipline ',
			name: 'selectDisc',	
			listeners: {
			   'select' : function(cmb, rec, idx) {
				   comboSociete.clearValue();
				   comboSociete.store.load({
						params: {'project': comboProject.getValue(), 'discipline': comboDiscipline.getValue()}
						});		   
					}
				}		
			});			
 
		var comboProject = new Ext.form.ComboBox({
			allowBlank: false,
			lazyRender: true,
			maxLength: 55,
			width: 110,		
			editable: false,
			emptyText: 'Select a project',		
			mode: 'local',
			triggerAction: 'all',
			store: storeProject,
			valueField: 'projectId',
			displayField: 'projectId',
			fieldLabel: 'Project ',
			name: 'selectPj',			
			listeners: {
			   'select' : function(cmb, rec, idx) {
				   comboDiscipline.clearValue();
				   comboDiscipline.store.load({
						params: {'project': comboProject.getValue() }
						});		   
					}
				}		
			});
 
		function  fct_submit() {
			formRptPj.form.submit({
				url: 'index.php?page=rapport_projet',
				method: 'GET'
				});
			};
 
		var formRptPj = new Ext.FormPanel({
			labelWidth: 75, // label settings here cascade unless overridden
			standardSubmit: true,
			url:'index.php?page=rapport_projet',
			renderTo:'formRptPj',
			frame:true,
			title: '...',
			bodyStyle:'padding:5px 5px 0',
			width: 350,
			defaults: {width: 230},
			defaultType: 'textfield',
			items: [comboProject,comboDiscipline,comboSociete,{
				xtype:'fieldset',
				title: 'During',
				collapsible: true,
				autoHeight:true,
				autoWidth:true,
				defaults: {width: 215},
				defaultType: 'datefield',
				items :[{
					fieldLabel: 'Start Date',
					name: 'startdt',
					id: 'startdt',
					vtype: 'daterange',
					endDateField: 'enddt' // id of the end date field
				},{
					fieldLabel: 'End Date',
					name: 'enddt',
					id: 'enddt',	
					vtype: 'daterange',
					startDateField: 'startdt' // id of the start date field
				}]}
				],
			buttons: [{
				text: 'Validate',
				handler : fct_submit
				}]
			});
 
		});
	</script>";
 
	//maintenant on s'occupe d'affiche le tout
	echo '<div id="formRptPj"></div>';
Merci de votre aide, bonne journée.