Hello to all my greetings after some time without appearing, but I have a detail I would like you to help me solve with the help of this magnificent forum.
The problem is that I am using multimoldelform to bring data to a texfield with ajax in a dropdownlist, but it only changes me in the first product, when trying to add more products they don’t change the texfields, this is my piece of code in the view:
$memberFormConfig = array(
'showErrorSummary' => true,
'elements' => array(
'Codprod' => array(
'type' => 'dropdownlist',
'prompt' => 'Seleccione',
'items' => CHtml::listData(TblMprima::model()->findAll(array('order' => 'NProductos', 'condition' => 'CodAlm=634181')), 'Codprod', 'NProductos', 'PreMay'),
// 'onChange' => 'javascript:ActualizarCodigo()',
'ajax' => array(
'type' => 'POST',
'url' => CController::createUrl('/contabilidad/transferecias/obtenerProducto'),
'dataType' => 'json',
''data' => array(
'incodigo' => 'js:this.value',
'idde' => 'js:$("#Transferencias_CodAlm").val()',
),
'success' => 'function(data) {
$("#Codprod").val(data.Codprod);
$("#NProductos").val(data.NProductos);
$("#Saldo").val(data.Saldo);
$("#Id_UM").val(data.Id_UM);
$("#PreMay").val(data.PreMay);
}',
),
),
in the controller I have this:
```
public function actionObtenerProducto() {
$codigo = $_POST['incodigo'];
$destino = $_POST['idde'];
$producto = TblMprima::model()->findByPk((string) $codigo);
if ($producto->CodAlm <> $_POST['idde'])
echo "error";
else
echo CJSON::encode(array(
'NProductos' => $producto->NProductos,
'Codprod' => $producto->Codprod,
'PreMay' => $producto->PreMay,
'Saldo' => $producto->Saldo,
'Id_UM' => $producto->Id_UM,
));
}
Please help with this, I need the textfield to be updated when changing to other products.
sincerely grateful