Log in

View Full Version : ***Defining valid fields - NEED HELP***


antialiasis
03-30-2006, 03:08 PM
Okay, since nobody was interested in porting Darth Cow's default BBCode hack when I asked, I started messing around on my own to make a similar hack, and strangely enough I managed to figure almost everything out, including adding a column for a "Use default BBCode for this post" option in the database. However, now I got an error:

Fatal error: Field usedefaultbbcode is not defined in $validfields in class vB_DataManager_Post in \includes\class_dm.php on line 485

I opened class_dm.php and searched for "vB_DataManager_Post", but the phrase is not found. Because my PHP knowledge is rather limited, I don't really get the instructions above "vB_DataManager", either. Any help, please?

antialiasis
03-31-2006, 04:46 PM
I seriously need help on this... I tried using this after reading the instructions above vB_DataManager a few times over:

$validfields["usedefaultbbcode"] = array('VF_TYPE' => 'TYPE_BOOL', 'VF_REQ' => 'REQ_NO', 'VF_CODE' => 'VF_METHOD');

But then I get a blank page. :/ I have no clue what I'm doing; can anybody give a hint?

JusteCards
04-01-2006, 12:35 AM
Try adding a plugin with the following at the userdata_start hook:
// check to make sure VB_AREA is defined
if (defined('VB_AREA'))
{
// add these to the validfields

$this->validfields['usedefaultbbcode'] = array(TYPE_BOOL, REQ_NO);
}

antialiasis
04-01-2006, 10:10 AM
Hmm, I'm still getting a blank page...

JusteCards
04-01-2006, 04:09 PM
Can't really help with that without seeing the rest of the code.

antialiasis
04-01-2006, 06:53 PM
Well, basically, I more or less went through newreply.php and includes/functions_newpost.php and everywhere it did something with the "Show your signature in this post?" input, I did the exact same thing with usedefaultbbcode.

antialiasis
04-02-2006, 08:09 PM
*prods thread* Anybody?

Airkat
06-09-2006, 05:02 PM
had a similar issue and found this thread, but then I figured it out, if you haven't here it is.

I originally added my new field right under the declaration of the validfields like so:


var $validfields = array();
$this->validfields['MYVAR'] = array(TYPE_INT, REQ_NO);



But then, duh, I realized, this is a class. You can't do random operations outside of functions and stuff, so if you move that to a function it works. I moved mine into

function vB_DataManager(&$registry, $errtype = ERRTYPE_STANDARD)

So it looks something like so:

function vB_DataManager(&$registry, $errtype = ERRTYPE_STANDARD)
{
if (!is_subclass_of($this, 'vB_DataManager'))
{
trigger_error("Direct Instantiation of vB_DataManager class prohibited.", E_USER_ERROR);
}

$this->validfields['MYVAR'] = array(TYPE_INT, REQ_NO);
///...rest of function