• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

The field xyz was not recognised.

MOZ

Well-known member
#1
I have been working on an addon and keep getting this error:
The field 'post_sticky' was not recognised.

Now I do have the below code in my DataWriter extender:

Code:
class StickyFirstPost_DataWriter_Discussion_Thread extends XFCP_StickyFirstPost_DataWriter_Discussion_Thread
{
/**
* Gets the fields that are defined for the table. See parent for explanation.
*
* @return array
*/
protected function _getFields()
{
$fields = parent::_getFields();
$fields['xf_thread']['post_sticky'] = array('type' => self::TYPE_UINT, 'default' => '0');
return $fields;
}
}
When I try to do this in my controller, I get an error:
Code:
$dw->set('post_sticky',$dwInput['post_sticky'],'xf_thread');
So what is wrong?
 

MOZ

Well-known member
#2
If I insert the below into XenForo_DataWriter_Discussion_Thread::_getFields(), it works properly.

Code:
$fields['xf_thread']['post_sticky'] = array('type' => self::TYPE_UINT, 'default' => '0');
 

MOZ

Well-known member
#3
On further investigation it revealed that the _getFields() method was not being invoked from my child class at all.

I can confirm that the class has been extended correctly because another function in the same child class is being called.

What could be the issue. If someone wants to have a look at the whole code of the addon, please let me know, I'll send over the code via PC.
 

Chris D

XenForo developer
Staff member
#4
I'm sure I've extended xf_thread fields before........ :cautious:

Feel free to send me the code if you wish... though I am aware I already have some code of yours that I've not sorted out for you yet... Too busy :unsure:
 

Chris D

XenForo developer
Staff member
#5
PHP:
	protected function _getFields()
	{	
		$parent = parent::_getFields();
		
		$parent['xf_thread']['thing'] = array(
			'stuff' => 'whatever'
		);
		
		Zend_Debug::dump($parent);
		
		return $parent;
	}
Ok, so I'm using the above code in my extended DataWriter... and it works... If I dump the $parent array, when I post a thread it generates a Javascript error and dumps it in the console. It looks a bit crap as it's basically JSON encoded but, it's definitely there:



The only thing I can think of is if you're using the wrong DataWriter somehow? Also, it's not necessary to specify "xf_thread" in the $dw->set it should know automatically what datawriter you're using.
 

MOZ

Well-known member
#6
I did something similar (Dumping $parent), but weird thing is, it wouldn't show up. Sending you the code.
 
#7
Typo alarm;)

$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
!=

$dw = XenForo_DataWriter::create('Xenforo_DataWriter_Discussion_Thread');

That's why your dw listener never extended it here
PHP:
if ($class == 'XenForo_DataWriter_Discussion_Thread')
{
$extend[] = 'StickyFirstPost_DataWriter_Discussion_Thread';
}
$class == Xenforo_DataWriter_Discussion_Thread => false
 

Chris D

XenForo developer
Staff member
#8
Typo alarm;)

$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
!=

$dw = XenForo_DataWriter::create('Xenforo_DataWriter_Discussion_Thread');

That's why your dw listener never extended it here
PHP:
if ($class == 'XenForo_DataWriter_Discussion_Thread')
{
$extend[] = 'StickyFirstPost_DataWriter_Discussion_Thread';
}
$class == Xenforo_DataWriter_Discussion_Thread => false
I can confirm this,