HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Developers' Forum (http://www.howtoforge.com/forums/forumdisplay.php?f=33)
-   -   onBeforeInsert generating table value (http://www.howtoforge.com/forums/showthread.php?t=60218)

mare 14th January 2013 17:46

onBeforeInsert generating table value
 
Hello,

I use onBeforeInsert in my table_edit.php to generate a value which should be added to the database (will come from another subsystem so it's not available during the form input).

currently i do the following but thing there is a better solution .

Code:

function onBeforeInsert()
            {
              global $app
              $app->tform->errorMessage = myfunction($_POST) ;
              $this->dataRecord['value'] = $_SESSION['value'] ;
              unset ($_SESSION['value']) ;
}

Code:

myfunction($_VAR)
{
global $_SESSION ;
...
if (ok)
$_SESSION['value'] = "foo";
(else)
return "error foo :-(" ;
}


till 14th January 2013 17:55

May you describe a bit more what you try to do. ISPConfig has various methods to validate and filter user input incl. custom validators and custom datasources for values. A custom validator or custom datasource is a php class which can handle nearly any kind of value and the validators and datasources are just configured in the tform file, there is no overriding of onBeforeInsert nescessary then.

mare 16th January 2013 14:15

I have a form with Value A and B

What i tried to find out was how to :

Entering Value A into a form --> submit the form --> use onBeforeInsert function in myform_edit.php to generate Value B and store this into the table.

So Value B is not entered by the user but generate by ispconfig.

I found that i simply can use $page->dataRecord['B'] = $result['object'] ; to fill B.

till 16th January 2013 15:54

Quote:

I found that i simply can use $page->dataRecord['B'] = $result['object'] ; to fill B.
Yes, thats correct. If B is defined in the tform file as table field, you can set B in dataRecord in any event function that gets executed before the insert or update happens.


All times are GMT +2. The time now is 14:09.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.