SAVE THE DATA
I want to share how I have created the solution to my problem.
Along with the plugin there is a component than is relate with the work I doing, and both will work together. The component has other purposes, but taking advantage of the fact that much of the logic that the plugin needs, is already made or is reusable through the model classes, such as JModelAdmin class. With that said, I reworked my onContentPrepareForm function to:
public function onContentPrepareForm(Form $form, $data)
{
// Check we are manipulating a valid form.
$name = $form->getName();
if (!in_array($name, array('com_content.article')))
{
return true;
}
// Load the form
$model = $this->_getModel('Tagimageform');
$model->loadFormFile('tagimageform', $form);
return true;
}
The _getModel end like:
protected function _getModel($name, $prefix = 'TagimagesModel')
{
// Add the models
JModelLegacy::addIncludePath($this->_com_path . '/models', $prefix);
// Extra paths where the model will look for
Form::addFormPath($this->_com_path . '/models/forms');
Table::addIncludePath($this->_com_path . '/tables');
// Get an instance of the generic form model
$model = JModelLegacy::getInstance($name, $prefix, array('ignore_request' => true));
return $model;
}
So far, the result still the same, we get the form when we are at the article edit view:

For save the values of the custom form, who is our goal, we used the onContentAfterSave event:
public function onContentAfterSave($context, $article, $isNew)
{
// Check we are handling the article form.
if ($context !== 'com_content.article')
{
return true;
}
$model = $this->_getModel('Tagimageform');
// Get the whole article form data including the custom form data
$input = Factory::getApplication()->input;
$formData = new Input($input->get('jform', '', 'array'));
// Get only the custom form data we will save
// Will be a array if was filled and null if not
$data = $formData->getRaw('config');
// Save the form data to the table
if (is_array($data))
{
// Our custom form is a "subform" type field
// We need save all the forms the user created because is a repeatable "subform"
foreach ($data as $value) {
try
{
$result = $model->save($value);
}
catch (\Exception $e)
{
Factory::getApplication()->enqueueMessage(
Text::sprintf('One of the form could not be saved', $value['cart'], 'error'));
}
}
}
}
And done, the new values were added to our table in the database successfully!
Now there are other actions such as loading the correct form/s if the user edits the article, but that is part of another story.
Thank you to @Benjamin Trenkle for the suggestion on Glip, of the corrects plugins events to work on.