Search the Community
Showing results for tags 'front-end form'.
-
Hi guys, Am having an issue with a front-end form where page-fields via a select field are not getting updated. Could someone check that my syntax is correct? I'm not really sure why they're not matching up. The form part: <label for="edit_terms">Terms</label> <select name="edit_terms"> <?php foreach ($pages->find("template=payment_term") as $term) { ?> <option value="<?php echo $term->id; ?>"<?php if ($term->id == $page->invoice_terms->id) {echo " selected";} ?>><?php echo $term->title; ?></option> <?php } ?> </select> <label for="edit_status">Status</label> <select name="edit_status"> <?php foreach ($pages->find("template=invoice_status") as $status) { ?> <option value="<?php echo $status->id; ?>"><?php echo $status->title; ?></option> <?php } ?> </select> The editing page via API part: <?php $error = 0; $out = ""; // Form was submitted if ($input->post->estimate_edit_submit) { $page_name = $sanitizer->pageName($input->post->number); $p = $pages->find("template=estimate, name=$page_name")->remove($page); if (count($p)) { $error = 1; $out = "Sorry, that page name is already taken..."; } if ($error == 0) { $page->of(false); // $page->parent = $pages->get("/estimates"); // $page->template = "estimate"; $page->title = $sanitizer->name($input->post->number); $page->name = $sanitizer->pageName($input->post->number); $page->invoice_number = $sanitizer->name($input->post->number); $page->invoice_date = $sanitizer->text($input->post->date); $page->invoice_client = $sanitizer->text($input->post->client); $page->invoice_terms = $sanitizer->text($input->post->edit_terms); $page->invoice_status = $sanitizer->text($input->post->edit_status); $page->invoice_line->removeAll(); $total = 0; for ( $i=0;$i<count($input->post->invoice_billable);$i++) { ${'rp'.$i} = $page->invoice_line->getNew(); ${'rp'.$i}->invoice_billable_line = $input->post->invoice_billable[$i]; ${'rp'.$i}->invoice_billable_amount = $input->post->line_value[$i]; $total += $input->post->line_value[$i]; } $page->invoice_total = $total; $page->save(); $out = "Estimate saved successfully"; } } All the text fields are getting updated but all three select fields (client, terms and status) aren't updating. I have an almost identical template for create instead of edit and everything works fine. Been scratching my head now for a good few hours, can anyone see anything wrong with the way I'm using the API? Thanks.
- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with: