New value in a combo box is not saved

I built a combo in a form and filled with a connector as shown below. The problem comes when I save a value that is not listed in the combo. The form data is saved but not the new values ​​entered manually in the combo.
How do I save a new value manually entered into a combo ?

Combo connector

<?php
require_once('config_areapec.php');
require_once('php/codebase/combo_connector.php');
$champ=$_GET["champ"];	
	$options = new ComboConnector($conn);
	switch	($champ){
		//test
		case "nom":
			$options->set_encoding("iso-8859-1");//sinon les accents dans la base font planter l'interface
			$options->render_sql("SELECT  distinct nom FROM test GROUP BY nom","nom","nom");
		break;
	}
	
?>

My form (extract)

//--- dhtmlXDataStore initialization. This dataStore is populated with data from DB  ---	
	var convention = new dhtmlXDataStore({  
		url:"convention_test.php",
		datatype:"xml"
	});
//---data scheme. Sets a default scheme for adding data records---
	convention.data.scheme({
		id_convention:"",
				etat:"test",
                nom:""		
	});
//---dataProcessor initialization. We use dataProcessor to implement Create/Update/Delete operations---
        myDP = new dataProcessor("convention_test.php");
		myDP.init(convention);
//---layout initialization and configuration ---
 	var layout = new dhtmlXLayoutObject("box","2U");
        layout.cells("a").setText("Liste des etats");
 		layout.cells("b").setText("Informations etats");
		layout.cells("a").setWidth(400);
		layout.cells("a").setHeight(50);
        layout.cells("a").setWidth(400);
		layout.cells("a").setHeight(50);
		//layout.cells("a").attachObject("box");
//---grid initialization and configuration ---	
    myGrid = layout.cells("a").attachGrid();
	myGrid.setImagePath("codebase/imgs/");
	myGrid.setSkin("dhx_skyblue");
	//myGrid.setColTypes("txt,dhxCalendarA");
	myGrid.setHeader("Etat,Nom");
	myGrid.setInitWidths("110,110");
	myGrid.setColumnIds("etat,nom");
	myGrid.setColTypes("ed,ed");

	myGrid.init();
//---form initialization and configuration ---	
	var formData = [
		{ type:"input",value:"", name:"etat", label:"Etat", width:100, labelWidth:"100", labelHeight:"21", inputWidth:"100", inputHeight:"21", labelLeft:"15", labelTop:"15", inputLeft:"15", inputTop:"36", position:"absolute"},

		{ type:"combo" , name:"nom", label:"nom", width:175, labelWidth:"175", labelHeight:"21", inputWidth:"175", inputHeight:"21", labelLeft:"215", labelTop:"15", inputLeft:"150", inputTop:"36", position:"absolute",connector:"combo_perso_test.php?champ=nom"  },
		{ type:"button" , name:"save", label:"OK", value:"OK", width:"40", inputWidth:"250", inputHeight:"21", labelLeft:"-10", labelTop:"-10", inputLeft:"15", inputTop:"180", position:"absolute"  },
		{ type:"button" , name:"add", label:"Ajout", value:"Création", width:"80", inputWidth:"80", inputHeight:"21", labelLeft:"-10", labelTop:"-10", inputLeft:"150", inputTop:"180", position:"absolute"  },
		{ type:"button" , name:"delete", label:"Suppression", value:"Suppression", width:"80", inputWidth:"80", inputHeight:"21", labelLeft:"-10", labelTop:"-10", inputLeft:"289", inputTop:"180", position:"absolute"  }
	];
	myForm = layout.cells("b").attachForm(formData);
 
//---binding the grid to the dataStore. Loading data from the dataStore to the grid---
	myGrid.sync(convention);
 
//--- binding the form to the grid. Presenting record's details in the form ---
	myForm.bind(myGrid);
 

//--- Create/Update/Delete operations ---	
	myForm.attachEvent("onButtonClick", function(id){
			if (id=='add'){//
				convention.add({}); //creates a new record that uses 'amc.data.scheme'	
			}
			else if (id=='save'){
				myForm.save(); //saves the made changes
			}
			else if (id=='delete'){ //deletes the selected row
				var selectedItem = myGrid.getSelectedRowId();
				convention.remove(selectedItem);
			}
    });	 

Please try to use attached file instead of the original one. It’ll solve the problem.
dhtmlxform_item_combo.zip (1.15 KB)

Hello,
Thank you for this file. I tested this file which has not solved the problem.
The new value in the combo is not used when saving the form.
To force the inclusion of the new value I used a few lines of code that work even if I do not find the solution very beautiful (if you have a better solution I took).
On the event “onBeforeValidate” Form I call a function that:
recovered the value in the combo,
recovered the index value in the combo box and if the index does not exist I add a line with this value to the combo and I select that line.

myForm.attachEvent("onBeforeValidate",function(id){
		comboPreValidation("nom");
		return true;//si true la validation et l'enregistrement se poursuivent.
		});
	function comboPreValidation(nomCombo){
		var monObjCombo=myForm.getCombo(nomCombo);
		var valueCombo = monObjCombo.getActualValue();//recupere la valeur affichée dans la combo
		var idxCombo=monObjCombo.getIndexByValue(valueCombo);//recupere l'index de valeur dans la combo
		if (idxCombo==-1){monObjCombo.addOption(valueCombo,valueCombo);} //si l'index=-1 alors la valeur n'existe pas dans la liste et on ajoute la valeur à la liste de la combo 
		var idxCombo=monObjCombo.getIndexByValue(valueCombo);//recupere l'index de valeur dans la combo
		monObjCombo.selectOption(idxCombo,false,false);//selectionne la valeur nouvellement inserée dans la liste pour qu'elle soit enregistrée avec les autres elements du formulaire.
	};

Hello,

Locally getFormData() returns the new value for the combo item when we are using the library I attached in the previous reply.

Hello,
Effectively getFormData() returns the new value for the combo item when i use the library but this new value is not saved when i’m using myForm.save() function. I think i will use getFormData() for a other utilisation it’s a good information, thx.