The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Dynamic Form Generation - 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: Dynamic Form Generation (/showthread.php?tid=714)



Dynamic Form Generation - shoropio - 09-03-2017

Could anyone tell me a little bit about this Dynamic Form Generation feature?


Dynamic Form Generation - Brandin - 09-03-2017

Its gone over here:
https://userspice.com/documentation-functions/

I've never really used it - other than just using it to look at the function.

@Mudmin might be able to explain it better


Dynamic Form Generation - mudmin - 09-03-2017

Yeah. There are a few auto generation features. The best ones are the ones that are designed to update the database (deal with $_POST), unless you want to have all fields be text. I'm probably not explaining that very well.

So let's say you have a table called "assets" with 20 columns in it. You would do something like this...

To EDIT a particular row of the assets table...
Code:
$t = 'assets';
Code:
$skip = ['id'];
Code:
generateForm($t,$id,$skip);
Then to process the form
Code:
$id = Input::get('id');
//make sure you are passing the id in the form itself
//do any checks you want to do here
Code:
$skipFields = ['create_type'];
Code:
$updateFields = updateFields2($_POST, $skipFields);
Code:
$db->insert('assets',$updateFields);
Code:
$db->update('assets',$id,$updateFields);

to ADD a row to that table...
Code:
$t = 'assets';
Code:
$skip = ['id'];
Code:
generateAddForm($t,$skip);

Then to process the form
//do any checks you want to do here
Code:
$skipFields = ['create_type'];
Code:
$updateFields = updateFields2($_POST, $skipFields);
Code:
$db->insert('assets',$updateFields);



Dynamic Form Generation - shoropio - 09-03-2017

I acknowledge that this is very much to my knowledge almost nil. This function is not for me, @Mudmin, @Brandin thank you guys.


Dynamic Form Generation - mudmin - 09-03-2017

We're happy to help if you give a little more info for what you're trying to do.