The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
generateAddForm - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: generateAddForm (/showthread.php?tid=954) |
generateAddForm - fly476 - 02-15-2018 Sooo.. How do you submit the form? I am able to display the form, and that works great. I added a "Submit" button, but nothing. Thanks, generateAddForm - mudmin - 02-15-2018 We're actually working on a new and really awesome form generator, but this function still works and will continue to. Essentially this function speeds up creating the form, but you still have to process it. So the syntax is Code: <form class="" action="" method="post"> Code: <?php generateAddForm('mqtt');?> Code: <input type='submit' value='submit' name='submit' class='form-control'> Code: </form> Then at the top of the page, you can do a dnd to see what the form is submitting and write your logic to process it. Code: if(!empty($_POST)){ Code: dnd($_POST); Code: } Sorry. There was no documentation on that. generateAddForm - mudmin - 02-15-2018 Here's a more detailed answer. Generally when you're inserting, you don't want to let people set the id field, so you can tell generateAddForm to skip it by doing this. (I'm choosing MQTT because it's a table you're not going to break by inserting random data) Code: <?php generateAddForm('mqtt',['id']);?> Then you can actually process the form somewhat automatically. Code: if(!empty($_POST)){ Code: $fields = updateFields2($_POST); //dnd($fields); //do any checks you want to do here. Code: $db->insert('mqtt',$fields); Code: bold("<br>New row inserted!"); Code: } generateAddForm - matthewra - 02-18-2018 This is great, is the new form generator going to allow select field type? generateAddForm - mudmin - 02-18-2018 Yes. The new one has a bunch of field types available and more on the way. You can also create "views" which are smaller versions of your existing forms as well as generate forms from existing db tables. I expect it out on Monday |