1

Good day.

I created a component using https://blog.astrid-guenther.de/en/joomla-custom-fields-im-frontend-integrieren/ https://blog.astrid-guenther.de/en/joomla-frontend-editing/
When editing an entry in the admin panel, the value of the user field is saved.
When editing a record on the site, the value of the user field is not saved.
Tell me what could be the problem?
My component https://github.com/antarey/com_test1
Thank you

3 Answers 3

2

Your component needs to implement Joomla\CMS\Fields\FieldsServiceInterface. It has two methods: getContexts() which returns an array with contexts as keys and human readable titles as values. And validateSection() which allows mapping a provided "section" to another one. In this case section refers to a part of context without component prefix. When plugins are triggered in your component during frontend editing,com_test.form context is used. You need to remap this to com_test.test1 to match context used in backend. So your validateSection() method should look like this:

public function validateSection($section, $item = null)
{
    if ($section === 'form')
    {
        return 'test1';
    }

    return $section;
}
0
1

Sharky Thanks for showing me where to look. It was necessary to add code

use Joomla\CMS\Fields\FieldsServiceInterface;
...
class Test1Component  ..,FieldsServiceInterface
0

I added the code in the file - administrator\components\com_test1\src\Extension\Test1Component.php.

public function validateSection($section, $item = null)
{
    if ($section === 'form')
    {
        return 'test1';
    }

    return $section;
}

public function getContexts(): array
{
    Factory::getLanguage()->load('com_test1', JPATH_ADMINISTRATOR);

    $contexts = array(
        'com_test1.test1'    => Text::_('COM_CONTENT'),
        'com_test1.categories' => Text::_('JCATEGORY')
    );

    return $contexts;
}

Unfortunately, it didn't help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.