The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
generateAddForm
#1
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,
  Reply
#2
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.
  Reply
#3
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);
//if you want to see what you have at this point...
//dnd($fields);
//do any checks you want to do here.
Code:
$db->insert('mqtt',$fields);
Code:
bold("<br>New row inserted!");
Code:
}

  Reply
#4
This is great, is the new form generator going to allow select field type?
  Reply
#5
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
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)