Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Flash messages after successful commenting #6

Open
sasilen opened this issue Nov 27, 2017 · 1 comment
Open

Flash messages after successful commenting #6

sasilen opened this issue Nov 27, 2017 · 1 comment

Comments

@sasilen
Copy link

sasilen commented Nov 27, 2017

After I leave comment by using comments plugin I get two messages:

You can't comment this
Your comment has been correctly added !

Anyways comments seems to be inserted correctly to the table.

Behavior doesn't catch my comments from the table because in inserting phase 'ref' used is 'Plugin.Model' but behavior tries to find ref with 'Model'. This might be because I am using comments plugin from the other plugin and I am not setting modelClass by hand and let the behavior figure it out.

Changing getAlias() to getRegistryAlias() in behavior fixes my case, might be that I am using this somehow wrong, I usually have these kind of problems with plugins. ;)

if (empty($this->getConfig('modelClass'))) {
  $this->setConfig('modelClass', $this->_table->getRegistryAlias());
}
$this->_table->hasMany('Comments', [
  'className' => $this->getConfig('commentClass'),
  'foreignKey' => $this->getConfig('foreignKey'),
  'order' => 'Comments.created ASC',
  'conditions' => ['Comments.ref' => "{$this->_table->getRegistryAlias()}"],
  'dependent' => true
]);
@sasilen
Copy link
Author

sasilen commented Dec 6, 2017

Of course behavior works If I define modelClass

$this->addBehavior('Kareylo/Comments.Commentable',['modelClass'=>'Plugin.Model]);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant