BD to Colorpicker on Form

Hi, i’m trying to load a value in a colopicker that is on a form.

In the example below, i have a grid and a form that shows the grid’s selected record. In the form i have the colorpicker and an input text too. The input text it’s loaded correctly but the colorpicker don’t.

Can you help me?

//Form
formStructure = [
{type:“settings”,position:“label-left”,labelWidth:85,labelAlign: “right”},
{type: “fieldset”,name:“marcha”, label: “Marcha”, list:[
{type:“input”, name:“titulo”, label:“Título:”},
{type:“colorpicker”, name:“backcolor”, label:“Color de fondo:”, value:"#FFFFFF", imagePath: “dhtmlx/dhtmlxColorPicker/codebase/imgs/”}
];

var myForm = new dhtmlXForm(“form_container”,formStructure);

//In the grid
function doOnRowSelected1(id) {
myForm.load(“data.php?id=”+ mygrid1.cells(id,0).getValue());
}

///data.php

<?php require_once ('utiles.php'); require_once('./connector/form_connector.php'); $id = $_GET['id']; $res = conectarse(); $sql = "SELECT id, titulo, encabezado, descripcion, fondo, backcolor FROM marchas WHERE id = $id"; $form = new FormConnector($res); $form->render_sql($sql,"id","titulo,backcolor"); ?>

Hi,

try to use attached file instead of the original. The problem has been fixed here.
dhtmlxform.zip (15 KB)

Thanks, It works ok now!

Now i’m trying to save the data loaded with some modifications. I tried to follow the standalone form step-by-step example, but I’m doing something wrong because the method save() does not work.

This is the code of the form:

///////Form
var formStructure = [
	{ type:"fieldset" , name:"frm", label:"Formulario", width:500, labelAlign:"left", position:"", list:[
	{ type:"settings" , labelWidth:"90", labelAlign:"right", position:"label-left"  },
	{ type:"input" , name:"id", label:"Id:", readonly:true, position:""  },
	{ type:"input" , name:"titulo", label:"Título:", position:""  },
	{ type:"colorpicker" , name:"backcolor", label:"Color de fondo:", value:"#FFFFFF", imagePath:'dhtmlx/dhtmlxColorPicker/codebase/imgs/', position:""  },
	{ type:"file" , name:"encabezado", label:"Encabezado:", position:""  },
	{ type:"file" , name:"descripcion", label:"Descripción:", position:""  },
	{ type:"file" , name:"fondo", label:"Fondo:", position:""  },
	{ type:"file" , name:"cartel", label:"Carteles:", position:""  }
	]  },
	{ type:"fieldset" , name:"mail", label:"Mail", width:500, position:"", list:[
	{ type:"input" , name:"subject_mail", label:"Subject:", inputWidth:"350", inputHeight:"60", position:""  },
	{ type:"input" , name:"html_mail", label:"Cuerpo (html):", inputWidth:"350", inputHeight:"60", position:""  },
	{ type:"settings" , labelWidth:"90", labelAlign:"right", position:"label-left"  }
	]  },
	{ type:"fieldset" , name:"facebook", label:"Facebook", width:500, position:"", list:[
	{ type:"input" , name:"titulo_facebook", label:"Título:", inputWidth:"350", position:""  },
	{ type:"input" , name:"link_facebook", label:"Link:", inputWidth:"350", position:""  },
	{ type:"input" , name:"mensaje_facebook", label:"Mensaje:", inputWidth:"350", inputHeight:"60", position:""  },
	{ type:"settings" , labelWidth:"90", labelAlign:"right", position:"label-left"  }
	]  },
	{ type:"fieldset" , name:"twitter", label:"Twitter", width:500, position:"", list:[
	{ type:"settings" , labelWidth:"90", labelAlign:"right", position:"label-left"  },
	{ type:"input" , name:"mensaje_twitter", label:"Mensaje:", inputWidth:"350", inputHeight:"60", position:""  }
	]  },
	{ type:"fieldset" , name:"soinco", label:"Sónico", width:500, position:"", list:[
	{ type:"input" , name:"titulo_sonico", label:"Título:", inputWidth:"350", position:""  },
	{ type:"input" , name:"link_sonico", label:"Link:", inputWidth:"350", position:""  },
	{ type:"settings" , labelWidth:"90", labelAlign:"right", position:"label-left"  }
	]  },
	{ type:"button" , name:"save", value:"Guardar", width:"100", position:""  },
	{ type:"button" , name:"new", value:"Nuevo", width:"100", position:""  }
];

var myForm = new dhtmlXForm("form_container",formStructure);
myForm.attachEvent("onButtonClick", function(id) {
	if (id == "save"){
		myForm.save();		
	}
});

var dp1 = new dataProcessor("data.php");//instatiate dataprocessor

dp1.init(myForm);//link form to dataprocessor

///////Grilla
	
function doOnRowSelected1(id) {
	myForm.load("data.php?id="+ mygrid1.cells(id,0).getValue());
}

This is the code of data.php

<?php require_once ('utiles.php'); require_once('./connector/form_connector.php'); $id = $_GET['id']; $res = conectarse(); $form = new FormConnector($res); $form->render_table("marchas","id","id,titulo,backcolor,html_mail,subject_mail,mensaje_facebook,titulo_facebook,link_facebook,mensaje_twitter,link_sonico,titulo_sonico"); ?>

Thanks.

a “colorpicker” value is not saved. The fixed dhtmlxform is attached.

Did you mean colorpicker value in “the method save() does not work” ? Or anything else ?
dhtmlxform.zip (15 KB)

The form it’s not recording any field. I think I’m doing something wrong, but i don´t know what it is. :frowning:

Please try to use the dhtmlxForm/samples/06_data/php/connector/dhtmlxdataprocessor.js It is attached. Hope it’ll resolve the problem.
dhtmlxdataprocessor.zip (4.96 KB)