1. 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.

Discussion in 'XenForo Development Discussions' started by MOZ, Feb 17, 2013.

  1. MOZ

    MOZ Well-Known Member

    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:

    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:
    So what is wrong?
  2. MOZ

    MOZ Well-Known Member

    If I insert the below into XenForo_DataWriter_Discussion_Thread::_getFields(), it works properly.

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

    MOZ Well-Known Member

    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.
  4. Chris D

    Chris D XenForo Developer Staff Member

    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:
  5. Chris D

    Chris D XenForo Developer Staff Member

        protected function _getFields()
    $parent parent::_getFields();
    $parent['xf_thread']['thing'] = array(
    'stuff' => 'whatever'
    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.
  6. MOZ

    MOZ Well-Known Member

    I did something similar (Dumping $parent), but weird thing is, it wouldn't show up. Sending you the code.
  7. havanaclub

    havanaclub Member

    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
    if ($class == 'XenForo_DataWriter_Discussion_Thread')
    $extend[] = 'StickyFirstPost_DataWriter_Discussion_Thread';
    $class == Xenforo_DataWriter_Discussion_Thread => false
  8. Chris D

    Chris D XenForo Developer Staff Member

    I can confirm this,
  9. MOZ

    MOZ Well-Known Member

    Damn caps. Thanks havanaclub!
  10. MOZ

    MOZ Well-Known Member

    Chris, now your turn to help me with the previous issue we talked about.

Share This Page