I have a little question, i’m using kartik/select2 widget to select product. i push the data from an arrayhelper -> map (id,product name).
My question is: how i could add in the a data-attribute like this : data-price=“12.0”
this my code for now : (i’m using dynamicform too, because i can add multiple products - just the code of the field)
Just don’t use ArrayHelper::map
Prepare you data like an array of objects [ {'id'=>$model->id, 'text'=>$model->product_name, 'data-price'=>$model->price}, { ... } ]
Thank you for your answer. Finally i did it in an other way,
i added a javascript function on the select change, to ask the controller for the product price.
That way i can get the product price, multiply it by the quantity selected and save directly the total.