Abhik
02-13-2012, 04:10 PM
Hello,
I have added two simple html text fields in newthread template and now want to save them using datamanager and show them in the showthread template.
First, I have placed them in GPC Array (in newthread_post_start hook):
$vbulletin->input->clean_array_gpc('p', array(
'domainforsalename' => TYPE_STR,
'domainforsalebnprice' => TYPE_STR,
));
$newpost['domainforsalename'] = $vbulletin->GPC['domainforsalename'];
$newpost['domainforsalebnprice'] = $vbulletin->GPC['domainforsalebnprice']; Second, I added the values (in newpost_process hook):
$domaindata =& datamanager_init('Thread', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$domaindata->setr('domainforsalename', $domainforsalename);
$domaindata->setr('domainforsalebnprice', $domainforsalebnprice);
$domaindata->setr('domainforsalename', $post['domainforsalename']);
$domaindata->setr('domainforsalebnprice', $post['domainforsalebnprice']);
$domaindata->pre_save();
if (count($domaindata->errors) > 0)
{
// Errors occurred. Do not proceed with the save.
// You may want to loop through $dataman->errors and
// display the results the user.
}
else
{
// No errors occurred.
// Proceed with the save (see the next step).
}
$domainforsalename = $domaindata->save();
$domainforsalebnprice = $domaindata->save();
// updating an existing record
$domaindata->save();And, finally validating the data (in threaddata_presave hook):
$this->validfields['domainforsalename'] = array(TYPE_STR, REQ_NO);
$this->validfields['domainforsalebnprice'] = array(TYPE_STR, REQ_NO);Still I am getting an error;
Fatal error: Field domainforsalename is not defined in $validfields in class vB_DataManager_Thread in [path]/includes/class_dm.php on line 515
What should I do?
I have added two simple html text fields in newthread template and now want to save them using datamanager and show them in the showthread template.
First, I have placed them in GPC Array (in newthread_post_start hook):
$vbulletin->input->clean_array_gpc('p', array(
'domainforsalename' => TYPE_STR,
'domainforsalebnprice' => TYPE_STR,
));
$newpost['domainforsalename'] = $vbulletin->GPC['domainforsalename'];
$newpost['domainforsalebnprice'] = $vbulletin->GPC['domainforsalebnprice']; Second, I added the values (in newpost_process hook):
$domaindata =& datamanager_init('Thread', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$domaindata->setr('domainforsalename', $domainforsalename);
$domaindata->setr('domainforsalebnprice', $domainforsalebnprice);
$domaindata->setr('domainforsalename', $post['domainforsalename']);
$domaindata->setr('domainforsalebnprice', $post['domainforsalebnprice']);
$domaindata->pre_save();
if (count($domaindata->errors) > 0)
{
// Errors occurred. Do not proceed with the save.
// You may want to loop through $dataman->errors and
// display the results the user.
}
else
{
// No errors occurred.
// Proceed with the save (see the next step).
}
$domainforsalename = $domaindata->save();
$domainforsalebnprice = $domaindata->save();
// updating an existing record
$domaindata->save();And, finally validating the data (in threaddata_presave hook):
$this->validfields['domainforsalename'] = array(TYPE_STR, REQ_NO);
$this->validfields['domainforsalebnprice'] = array(TYPE_STR, REQ_NO);Still I am getting an error;
Fatal error: Field domainforsalename is not defined in $validfields in class vB_DataManager_Thread in [path]/includes/class_dm.php on line 515
What should I do?