Fix rendering content form on external modules (#5765)

* Fix rendering content form on external modules

* CHANGELOG Update (#5765)
This commit is contained in:
Yuriy Bakhtin 2022-06-22 16:27:20 +03:00 committed by GitHub
parent 688c560289
commit b5aaebcb2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 9 deletions

View File

@ -13,4 +13,5 @@
- Enh #5598: Added `cy` Welsh language
- Fix #5338: Content topic/visibility changes are re-indexed in search index
- Enh #5535: Invisible users
- Enh #5747: Switch Mailer Library to `Symfony Mailer`
- Enh #5747: Switch Mailer Library to `Symfony Mailer`
- Fix #5765: Fix rendering content form on external modules

View File

@ -68,14 +68,24 @@ class WallCreateContentForm extends Widget
/**
* Returns the custom form implementation.
*
* @param ActiveForm
* @return string
*/
public function renderForm(ActiveForm $form): string
public function renderForm()
{
return '';
}
/**
* Returns the custom form implementation.
*
* @param ActiveForm $form
* @return string
*/
public function renderActiveForm(ActiveForm $form): string
{
return $this->renderForm();
}
/**
* @inheritdoc
*/

View File

@ -42,7 +42,7 @@ $pickerUrl = ($contentContainer instanceof Space) ? $contentContainer->createUrl
<div class="panel-body" id="contentFormBody" style="display:none;" data-action-component="content.form.CreateForm" >
<?php $form = ActiveForm::begin(['acknowledge' => true]); ?>
<?= $wallCreateContentForm->renderForm($form) ?>
<?= $wallCreateContentForm->renderActiveForm($form) ?>
<div id="notifyUserContainer" class="form-group" style="margin-top: 15px;display:none;">
<?= UserPickerField::widget([

View File

@ -35,17 +35,35 @@ class Form extends WallCreateContentForm
public $mentioningUrl = '/search/mentioning/space';
/**
* @inheritdoc
* Get params for form rendering
*
* @param array $additionalParams
* @return array
*/
public function renderForm(ActiveForm $form): string
public function getRenderParams(array $additionalParams = []): array
{
$canCreatePostInSpace = ($this->contentContainer instanceof Space && $this->contentContainer->can(CreatePost::class));
return $this->render('form', [
'form' => $form,
return array_merge([
'post' => new Post($this->contentContainer),
'mentioningUrl' => $canCreatePostInSpace ? Url::to([$this->mentioningUrl, 'id' => $this->contentContainer->id]) : null,
]);
], $additionalParams);
}
/**
* @inheritdoc
*/
public function renderForm(): string
{
return $this->render('form', $this->getRenderParams());
}
/**
* @inheritdoc
*/
public function renderActiveForm(ActiveForm $form): string
{
return $this->render('form', $this->getRenderParams(['form' => $form]));
}
/**