1

I don't know how to enable editing the created date of an article in the front-end, after updating to Joomla 3.8.10.

So far I used to override the article's edit form

com_content -> form > edit #line 120 :

<?php echo $this->form->renderField('created'); ?>

as suggested in this article: How to edit 'created date' from front end, and all was fine.

However, this no longer works with version 3.8.10.

How can I do it?

1 Answer 1

1

Created field in frontend article form contains unset filter. This filter prevents field value from saving. You can change the filter with a content plugin. The example below also sets showtime attribute to true in case you want to enter time like in other date fields.

defined('_JEXEC') or die;

use Joomla\CMS\Form\Form;
use Joomla\CMS\Plugin\CMSPlugin;

class PlgContentExample extends CMSPlugin
{
    protected $app;

    public function onContentPrepareForm(Form $form, $data)
    {
        if ($this->app->isClient('site') && $form->getName() === 'com_content.article')
        {
            $form->setFieldAttribute('created', 'filter', 'user_utc');
            $form->setFieldAttribute('created', 'showtime', 'true');
        }

        return true;
    }
}

Note, the template override is still required to render the field.

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.