XF 2.1 Old title returned without page reload

CMTV

Well-known member
My entity class has a MasterTitle relation and title getter:
PHP:
public function getTitle()
{
    $definition = $this->Definition;
    $paramPhrase = \XF::phrase($this->getPhraseName());
    return $paramPhrase->render('html', ['nameOnInvalid' => false]) ?: ($definition ? $definition->title : '');
}

I am trying to save an entity and immediately return it to the page without reloading.

The problem is that it simply does not work. For some reason this method returns the old entity title, not the updated one. It returns the actual updated title only after reloading the page...

It looks strange since the code below works fine and always return the actual updated value after saving. No page reloading required:
PHP:
public function getTitle()
{
    return $paramPhrase = \XF::phrase($this->getPhraseName());
}

But I need to use $definition->title if entity does not have title...

Sure the problem lies here:
$paramPhrase->render('html', ['nameOnInvalid' => false]) ?: ($definition ? $definition->title : '');

But for now I can't really get to where the problem is...
 
Last edited:
Top