public function beforeSave()
    {
        $tag = $this->getElement('tag')->getValue();
        //wyszukanie tagu
        if (null === $tagRecord = (new \Cms\Orm\CmsTagQuery)
            ->whereTag()->equals($tag)
            ->findFirst()) {
            //utworzenie tagu
            $tagRecord = new \Cms\Orm\CmsTagRecord;
            $tagRecord->tag = $tag;
            $tagRecord->save();
        }
        //przypisanie id tagu
        $this->getRecord()->cmsTagId = $tagRecord->id;
        return true;
    }