Not loading my database field... something simple I'm sure
This extension is fantastic! It is just what I wanted to eliminate some troublesome checkboxes and be more Web 2.0-ish. Thank you!
I am very close to having my implementation done. My problem is my lack of knowledge of javascript. I've updated my project to ExtJs 3.1.0. The SuperBoxSelect is working perfectly showing my local list of items. What is not happening is the loading of the database field of all the selections. I am only sending to the database the last selection that was made.
Here is what I've got for code snippets. First the definition of the SuperBoxSelect:
Code:
var servicesCombo = new Ext.ux.form.SuperBoxSelect({
id: 'services1',
fieldLabel: 'Service(s) Rendered',
emptyText: 'Select service(s) rendered...',
resizable: true,
minChars: 2,
store: [
'AirCondEvap', 'DieselFuelSys', 'GasFuelSys', 'Battery', 'BrakeFlush', 'Driveline',
'Transmission', 'CoolingSys', 'PowerSteer'
],
mode: 'local',
forceSelection: true,
triggerAction: 'all',
name: 'data[Repairorder][services]',
hiddenName: 'data[Repairorder][services]',
selectOnFocus:true
});
Pretty simple stuff. The hiddenName has been how I have loaded other combo boxes. The format of the name is for sending back to CakePHP the database field. [Repairorder] is the model name (database table) and [services] is the field. It is defined as a VARCHAR(150) in a MySQL MyISAM database.
Here is what I have for a handler on the save button:
Code:
buttons: [{
text: 'Save', // text for submit button
type: 'submit', // type for button
handler: function() { // when you click the button...
alert(Ext.getCmp('services1').getValue());
add_form.form.submit({
url: 'http://'+host+'/repairorders/add_save',
waitMsg:'Saving Data...',
success: function() {
and so on...
The code in bold was just a debug aid to pop an alert box. The alert box always has all the values that were selected.
Would someone be so kind as to help me put the contents in my database field please? I know this is a newbie type question but I have experimented around and cannot discern the answer myself.
Thank you in advance!
Followup with POST data example
Did some more scratching around and here is the POST data that is going back to the server:
Code:
data[Repairorder][advisor_id]1
data[Repairorder][dealer_id]1
data[Repairorder][distributor_id]1
data[Repairorder][lof]Premium
data[Repairorder][make]Toyota
data[Repairorder][model]4-Runner
data[Repairorder][number]RO20100107b
data[Repairorder][odometer]13456
data[Repairorder][odometer_type]Miles
data[Repairorder][servicedate]2010-01-07
data[Repairorder][services]
data[Repairorder][services]AirCondEvap
data[Repairorder][services]Battery
data[Repairorder][services]BrakeFlush
data[Repairorder][vin]5TDZT34A05S250524
data[Repairorder][year]2008
What is interesting is that all three choices show up, but they are not delimited by commas as in the alert box. I can see now why only the last selection is loaded to the database. Does this help? How do I keep the delimited values?