CMS tutorial beforeSave with tag_string

Hi,
I’m finally moving from cakePhp2 to Cakephp4

So I’ve decided to follow the CMS tutorial, and when adding the virtual field tag_string, there is something I don"t understand. (https://book.cakephp.org/4/fr/tutorials-and-examples/cms/tags-and-users.html)

In the beforeFilter function I’ve debug the $entity.
In this entity I can see the field ‘tag_string’ with the updated value (coming from the form), and if I try to debug $entity->tag_string, I can see the ‘old’ version of it, not the dirty version.

It seems it’s due to the protected function _getTagString that detect $this->_properties[‘tag_string’] as null.

So what am I missing?

I thought this function was really usefull, but I can’t seem to make it work.
I’ve checked on the Bookmark tuto as well, and it’s exactly the same code.

Thanks if someone comes by and help me

edit : I’ve tried changing the function _getTagString() to _getTagString($tag_string), and this way I can access the $tag_string (updated version) and it seems to be working.
Hope it can help someone else.

regards
Max

You are right, the full correct function is:

	protected function _getTagString($tag_string)
	{
			if (isset($tag_string)) {
					return $tag_string;
			}
			if (empty($this->tags)) {
					return '';
			}
			$tags = new Collection($this->tags);
			$str = $tags->reduce(function ($string, $tag) {
					return $string . $tag->title . ', ';
			}, '');
			return trim($str, ', ');
	}

They should update CMS tutorial, case all this research maybe is not in begginers hand…