How to Insert from selectMulti field

3 months ago

+
0
-

How best to insert data from

<?php
$form->addMultiSelect('my_field', 'My Label:', $my_var)
     ->setRequired('My Label is required.');
?>

Doing a foreach seems a bit crude.
How is this handled in nette?

<?php
foreach( $values->my_field as $my_id){
    $db->table('my_table')->insert($other_id, $my_id);
}
?>

3 months ago

Pavel Kravčík
Member | 1001
+
0
-

3 months ago

+
0
-

Pavel Kravčík wrote:

What about multi-insert?
https://doc.nette.org/…ase-explorer#…

This would still require a foreach loop, to create the values.