Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 14th January 2013, 17:46
mare mare is offline
Junior Member
 
Join Date: Mar 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 :-(" ;
}
Reply With Quote
Sponsored Links
  #2  
Old 14th January 2013, 17:55
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,006
Thanks: 826
Thanked 5,377 Times in 4,224 Posts
Default

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.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 16th January 2013, 14:15
mare mare is offline
Junior Member
 
Join Date: Mar 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
  #4  
Old 16th January 2013, 15:54
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,006
Thanks: 826
Thanked 5,377 Times in 4,224 Posts
 
Default

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.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Courier Imap is not working HellMind General 5 12th April 2012 01:04
table lookup problem aurelius Installation/Configuration 5 2nd November 2011 19:12
server.sh not starting up tuxillo Installation/Configuration 8 31st December 2010 14:14
ISPConfig3 Mail Warn Errors reason8 General 3 25th November 2009 13:58
Howto analyse a IPTables firewall issue? chillifire Installation/Configuration 2 27th August 2008 07:23


All times are GMT +2. The time now is 22:04.


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