pwfans Posted May 6, 2020 Posted May 6, 2020 php code to create multiple pages : if ($input->post->submit) { $amount = count($input->post->field_1); for($i=0;$i<$amount;$i++) { $p = new Page(); $p->template = "template_1"; $p->parent = wire('pages')->get("/parent_1/"); $p->title = $input->post->field_1[$i]; $p->name = $input->post->field_1[$i]; foreach ($input->post->field_2 as $result) { $p->text.= $result." "; } $p->save(); } } html code : <tr> <td><input type="text" name="field_1"></td> <td> <select name="field_2[]" multiple="multiple"> <option value="opt_1">opt_1</option> <option value="opt_2">opt_2</option> <option value="opt_3">opt_3</option> </select> </td> </tr> <tr> <td><input type="text" name="field_1"></td> <td> <select name="field_2[]" multiple="multiple"> <option value="opt_1">opt_1</option> <option value="opt_2">opt_2</option> <option value="opt_3">opt_3</option> </select> </td> </tr> ... and another <tr>..</tr> addition using javascript There is off course incorrect value on field_2, they will contain same data get from field_2 on first row. Have try on google search and not found any solution yet, there are talk about multi-dimensional array but still not understand how to implement that.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now