i have created my first plugin and have hit a bit of a wall... its a plugin with a custom element type, i have it creating its own database table (migrations/install.php) and i have the form displaying, and the bit i am struggling with is the saving bit. I build a new element type based on the form details, then do a Craft::$app->getElements()->saveElement($song); ($song is my element type) , i keep getting a getSection method missing error from my Song element type, but i dont have a sectionId, or need a section for this as it is stored entirely in its own table, what have i not understood about creating and saving a custom element type?
Is there a demo plugin or some example i can learn from?
This is my controller
new SongElementType(); $SongElementType->name = Craft::$app->request->getParam('name', $SongElementType->name); $SongElementType->band = Craft::$app->request->getParam('band', $SongElementType->band);
then i call save that is in my service from my controller like so:
$this->trigger(self::EVENT_SONG_SAVED_BEFORE, new SongEvent([ 'song' => $song, 'isNew' => $isNew, ])); $success = Craft::$app->getElements()->saveElement($song); $this->trigger(self::EVENT_SONG_SAVED_AFTER, new SongEvent([ 'song' => $song, 'isNew' => $isNew, ]));
but i get this error:
Calling unknown method: robsplugin\songscatalogue\elements\Song::getSection()
where am i going wrong?