Hello everyone!
I have this simple form for creating purchase orders, there you have to select the Product (wich loads from the products table via Kartik’s select2 widget) the amount of items and the product price per unit, finally in the last column the total amount is read only and calculated by javascript.
http : //i36.photobucket . com/albums/e8/felipe-carrasco/create_pedido_zpscln58f9b.jpeg
What I want to achieve is to add new rows dynamycally with a button (10 max for example) as you need them, and then insert all rows into DB.
Is there a simple way to do this, a widget maybe?
Thank you and regards!
PS.: since I’m new to the forum I had to put some spaces in the image link.
Hello everyone!
I have this simple form for creating purchase orders, there you have to select the Product (wich loads from the products table via Kartik’s select2 widget) the amount of items and the product price per unit, finally in the last column the total amount is read only and calculated by javascript.
http : //i36.photobucket . com/albums/e8/felipe-carrasco/create_pedido_zpscln58f9b.jpeg
What I want to achieve is to add new rows dynamycally with a button (10 max for example) as you need them, and then insert all rows into DB.
Is there a simple way to do this, a widget maybe?
Thank you and regards!
PS.: since I’m new to the forum I had to put some spaces in the image link.
You can use javascript for adding new rows dynamically.
For inserting into DB you may need to use Command::batchInsert().
see http://www.yiiframework.com/doc-2.0/yii-db-command.html#batchInsert()-detail
aisogroup
(E Poremchuk)
August 20, 2015, 5:50am
4
Hi, Filipe!
Your question discused recently right here - http://stackoverflow.com/questions/23242340/yii-dynamically-add-row-on-ajax-action // Check out link above
Hope it will helpful for you.
P.S.
Additionaly have a look at ‘Yii Dynamic Form’ here - https://github.com/wbraganca/yii2-dynamicform
Hi,
Here is another thread that helped me:
http://www.yiiframework.com/forum/index.php/topic/53537-dynamic-tabular-input-form/
Even when there is no "final solution" posted it will teach you the some principles how to do it.
Regards
chrisb34
(Chrisb)
August 20, 2015, 7:48am
6
Thank you all!, I’ll take a look at those pages and try what suits better for my project.
Best regards.