mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Disable post message required validation when post has attached files (#7151)
* Disable post message required validation when post has attached files * Disable post message required validation when post has attached files
This commit is contained in:
parent
1a4d186c75
commit
7625750d4b
@ -14,6 +14,7 @@ HumHub Changelog
|
||||
- Enh #7138: Added missing DB relations to UserInvite model
|
||||
- Enh #7139 : Export `confirmUnload` function from `humhub.client.js`
|
||||
- Enh #7144: Add `DeviceDetectorHelper` class to detect devices such as the mobile app
|
||||
- Fix #7151: Disable new post's required validation for `message` when post has attached files
|
||||
|
||||
1.16.2 (Unreleased)
|
||||
---------------------
|
||||
|
@ -80,6 +80,10 @@ class PostController extends ContentContainerController
|
||||
|
||||
$post->load(Yii::$app->request->post(), 'Post');
|
||||
|
||||
if (!empty(Yii::$app->request->post('fileList'))) {
|
||||
$post->scenario = Post::SCENARIO_HAS_FILES;
|
||||
}
|
||||
|
||||
return Post::getDb()->transaction(function ($db) use ($post) {
|
||||
return WallCreateContentForm::create($post, $this->contentContainer);
|
||||
});
|
||||
|
@ -44,10 +44,15 @@ class Post extends ContentActiveRecord
|
||||
public $canMove = CreatePost::class;
|
||||
|
||||
/**
|
||||
* Scenarios
|
||||
* Scenario - when validating with ajax
|
||||
*/
|
||||
public const SCENARIO_AJAX_VALIDATION = 'ajaxValidation';
|
||||
|
||||
/**
|
||||
* Scenario - when related content has attached files
|
||||
*/
|
||||
public const SCENARIO_HAS_FILES = 'hasFiles';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@ -67,7 +72,7 @@ class Post extends ContentActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['message'], 'required', 'except' => self::SCENARIO_AJAX_VALIDATION],
|
||||
[['message'], 'required', 'except' => [self::SCENARIO_AJAX_VALIDATION, self::SCENARIO_HAS_FILES]],
|
||||
[['message'], 'string'],
|
||||
[['url'], 'string', 'max' => 255],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user