Hi everyone,
I’m using the widget WhTypeAhead on a form.
In this form I have two fields, the first is a simple textField, and the second is the WhTypeAhead.
The WhTypeAhead widget works perfectly, here the reference link.
My question is when do submit the form.
What is the correct or recommended way to perform submit because the WhTypeAhead sends the display value instead of hidden value.
<?php echo $form->textFieldControlGroup($model,'nombre',array('span'=>5,'maxlength'=>200, 'placeholder'=>'Descripcion')); ?>
<?php
$this->widget('yiiwheels.widgets.typeahead.WhTypeAhead', array(
'model'=>$model,
'attribute' => 'idzonapadre',
'htmlOptions'=>array(
'placeholder'=>'Zona Padre',
'autocomplete'=>'off',
),
'debugMode'=>true,
'pluginOptions' => array(
'name' => 'zonas',
'source'=>"js:function (query, process) {
zonas = [];
map = {};
$.getJSON('".$this->createUrl("zona/SearchByName")."', {name: query})
.done(function(data){
$.each(data, function(i, zona){
map[zona.nombre] = zona;
zonas.push(zona.nombre);
})
process(zonas);
})
.fail(function(jqxhr, textStatus, error){
var err = textStatus + \", \" + error;
console.log( \"Request Failed: \" + err );
});
}",
'matcher'=>'js:function (item) {
if (item.toLowerCase().indexOf(this.query.trim().toLowerCase()) != -1) {
return true;
}
}',
'sorter'=>"js:function (items) {
console.log(items);
return items.sort();
}",
'highlighter'=>"js:function (item) {
var regex = new RegExp( '(' + this.query + ')', 'gi' );
return item.replace( regex, \"<strong>$1</strong>\" );
}",
'updater'=>"js:function (item) {
selectedZona = map[item].idzona;
return item;
}",
)
));
?>
Thanks