Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.4.3 - (Unreleased)
---------------------------
- Enh #164: Convert swagger docs to OpenAPI 3.0
- Fix: New Poll missing Answers validation

1.4.2 (November 11, 2025)
-------------------------
Expand Down
10 changes: 5 additions & 5 deletions views/poll/edit.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

use humhub\modules\content\widgets\richtext\RichTextField;
use humhub\widgets\form\ActiveForm;
use humhub\helpers\Html;
use humhub\modules\content\widgets\richtext\RichTextField;
use humhub\modules\polls\widgets\AddAnswerInput;
use humhub\widgets\bootstrap\Button;
use humhub\widgets\bootstrap\Alert;
use humhub\modules\ui\icon\widgets\Icon;
use humhub\widgets\bootstrap\Alert;
use humhub\widgets\bootstrap\Button;
use humhub\widgets\form\ActiveForm;

/** @var $poll \humhub\modules\polls\models\Poll */

Expand Down Expand Up @@ -42,7 +42,7 @@ class="form-control tt poll_answer_old_input"
<?php endforeach; ?>

<?php if (!$poll->closed) : ?>
<?= AddAnswerInput::widget(['name' => 'newAnswers[]', 'showTitle' => true]); ?>
<?= AddAnswerInput::widget(['model' => $poll, 'name' => 'newAnswers[]', 'showTitle' => true]); ?>
<?php endif; ?>


Expand Down
8 changes: 7 additions & 1 deletion widgets/AddAnswerInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace humhub\modules\polls\widgets;

use humhub\components\Widget;
use humhub\modules\polls\models\Poll;

/**
* PollWallEntryWidget is used to display a poll inside the stream.
Expand All @@ -15,12 +16,17 @@
*/
class AddAnswerInput extends Widget
{
public Poll $model;
public $name;
public $showTitle;

public function run()
{
return $this->render('addAnswersInput', ['name' => $this->name, 'showTitle' => $this->showTitle]);
return $this->render('addAnswersInput', [
'model' => $this->model,
'name' => $this->name,
'showTitle' => $this->showTitle,
]);
}

}
21 changes: 13 additions & 8 deletions widgets/views/addAnswersInput.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

use humhub\helpers\Html;
use humhub\modules\polls\models\Poll;
use humhub\modules\ui\icon\widgets\Icon;

/* @var $model Poll */
/* @var $name String */
/* @var $showTitle Boolean */

Expand All @@ -10,21 +13,23 @@

<div class="mb-3">
<div class="input-group">
<input type="text" name="<?= $name ?>"
class="form-control poll_answer_new_input contentForm"
placeholder="<?= Yii::t('PollsModule.base', "Add answer...") ?>"
title="<?= $title ?>"/>
<?= Html::activeInput('text', $model, $name, [
'class' => 'form-control poll_answer_new_input contentForm',
'placeholder' => Yii::t('PollsModule.base', "Add answer..."),
'title' => $title,
]) ?>
<div class="input-group-text" style="cursor:pointer;" data-action-click="removePollAnswer">
<?= Icon::get('trash') ?>
</div>
</div>
</div>
<div class="mb-3">
<div class="input-group">
<input type="text" name="<?= $name ?>"
class="form-control poll_answer_new_input contentForm"
placeholder="<?= Yii::t('PollsModule.base', "Add answer...") ?>"
title="<?= $title ?>"/>
<?= Html::activeInput('text', $model, $name, [
'class' => 'form-control poll_answer_new_input contentForm',
'placeholder' => Yii::t('PollsModule.base', "Add answer..."),
'title' => $title,
]) ?>
<div class="input-group-text addPollAnswerButton" data-action-click="addPollAnswer" style="cursor:pointer">
<?= Icon::get('plus') ?>
</div>
Expand Down
4 changes: 2 additions & 2 deletions widgets/views/form.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

use humhub\helpers\Html;
use humhub\modules\content\widgets\richtext\RichTextField;
use humhub\modules\content\widgets\WallCreateContentFormFooter;
use humhub\modules\polls\assets\PollsAsset;
use humhub\modules\polls\models\Poll;
use humhub\modules\polls\widgets\AddAnswerInput;
use humhub\widgets\form\ActiveForm;
use humhub\helpers\Html;

/* @var $model Poll */
/* @var $form ActiveForm */
Expand All @@ -23,7 +23,7 @@
])->label(false) ?>

<?= Html::activeLabel($model, 'answersText', ['label' => Yii::t('PollsModule.base', 'Answers'), 'class' => 'control-label']); ?>
<?= AddAnswerInput::widget(['name' => 'newAnswers[]', 'showTitle' => false]); ?>
<?= AddAnswerInput::widget(['model' => $model, 'name' => 'newAnswers[]', 'showTitle' => false]); ?>

<div class="container">
<div class="row">
Expand Down