Forums

Problem with Chronoforms v4

reziel10 03 Oct, 2011
Hi,
'm doing the porting of my registration form from chronoform v3 to v4.I use this function:

$MyForm =& CFChronoForm::getInstance("Registrazione_utenti");
		if($MyForm->formparams("dbconnection") == "Yes"){
			$user = JFactory::getUser();			
			$row =& JTable::getInstance("utenti", "Table");


in chronoform v3 work perfecty, but when i use the same code in v4 there is this problem:

Fatal error: Call to undefined method CFChronoForm::formparams() in C:\xampp 1.7.1\htdocs\Joomla\administrator\components\com_chronoforms\form_actions\custom_code\custom_code.php(18) : eval()'d code on line 3
plese help me!!!
GreyHead 03 Oct, 2011
Hi reziel10 ,

I'm afraid that a lot of the ChronoForms code has changed :-(

What does this code block do? There may be a simpler way of setting it up in CFv4.

Bob
reziel10 03 Oct, 2011
thanks for quick response, this code is in an event custom code(on submit) and i use it to insert the some user data in a table jos_utenti becouse i need to share information in various tables. i post all code of the event....however i complete the porting from the v3 to the v4...this is my last problem.
there is the code of the event:

<?php
	$MyForm =& CFChronoForm::getInstance("Registrazione_utenti");
		if($MyForm->formparams("dbconnection") == "Yes"){
			$user = JFactory::getUser();			
			$row =& JTable::getInstance("utenti", "Table");
			srand((double)microtime()*10000);
			$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16).md5(uniqid(mt_rand(), true));
			JRequest::setVar( "recordtime", JRequest::getVar( "recordtime", date("Y-m-d")." - ".date("H:i:s"), "post", "string", "" ));
			JRequest::setVar( "ipaddress", JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" ));
			JRequest::setVar( "uid", JRequest::getVar( "uid", $inum, "post", "string", "" ));
			JRequest::setVar( "cf_user_id", JRequest::getVar( "cf_user_id", $user->id, "post", "int", "" ));
			$post = JRequest::get( "post" , JREQUEST_ALLOWRAW );			
			if (!$row->bind( $post )) {
				JError::raiseWarning(100, $row->getError());
			}				
			if (!$row->store()) {
				JError::raiseWarning(100, $row->getError());
			}
			$MyForm->tablerow["jos_utenti"] = $row;
		}
?>
GreyHead 04 Oct, 2011
Hi reziel10,

In ChronoForms v4 you should be able to do this with a DB Save action after the Joomla! Registration action. The Registration action puts the user info into a object at $form-> data['_PLUGINS_']['joomla_registration']

A bit of custom code is probably going to be needed to switch this into a format that the DB Save can use. Please try
<?php
$form->data['new_user'] = array();
foreach ( $form-> data['_PLUGINS_']['joomla_registration'] as $k => $v ) {
  $form->data['new_user'][$k] = $v;
}
?>
If this works that I think that using a Model ID of 'new_user' in the DB Save should go the trick. Note: not tested and will need debugging!

Bob
This topic is locked and no more replies can be posted.