diff --git a/src/Controller/FediPlanController.php b/src/Controller/FediPlanController.php index ebca7bf..2fdf5ed 100644 --- a/src/Controller/FediPlanController.php +++ b/src/Controller/FediPlanController.php @@ -191,7 +191,12 @@ class FediPlanController extends AbstractController } $params['sensitive'] = ($data->getSensitive() == null || !$data->getSensitive()) ? false : true; - $pollOptions = $data->getPollOptions(); + if($data->getAttachPoll() > 0) { + $pollOptions = $data->getPollOptions(); + } else{ + $pollOptions = array(); + } + $pollExpiresAt = $data->getPollExpiresAt(); $isPollMultiple = $data->isPollMultiple(); if (count($pollOptions) > 0) { diff --git a/src/Form/ComposeType.php b/src/Form/ComposeType.php index 5f09f17..4f30b69 100644 --- a/src/Form/ComposeType.php +++ b/src/Form/ComposeType.php @@ -19,6 +19,7 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\DateTimeType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -76,6 +77,8 @@ class ComposeType extends AbstractType 'data' => $user->getDefaultVisibility(), 'label' => 'page.schedule.form.visibility', 'translation_domain' => 'fediplan']); + $builder->add('attach_poll', HiddenType::class, ['required' => true, 'empty_data' => 0]); + $builder->add('timeZone', TimezoneType::class, [ 'label' => 'page.schedule.form.timeZone', diff --git a/src/SocialEntity/Compose.php b/src/SocialEntity/Compose.php index 2fad67b..ed41b03 100644 --- a/src/SocialEntity/Compose.php +++ b/src/SocialEntity/Compose.php @@ -26,6 +26,17 @@ class Compose private ?int $poll_expires_at = null; private ?bool $poll_multiple = null; + public function getAttachPoll(): ?bool + { + return $this->attach_poll; + } + + public function setAttachPoll(?bool $attach_poll): void + { + $this->attach_poll = $attach_poll; + } + private ?bool $attach_poll = null; + public function __construct() { $this->poll_options = array(); diff --git a/templates/fediplan/schedule.html.twig b/templates/fediplan/schedule.html.twig index 4cbf4e6..ab7b4e8 100644 --- a/templates/fediplan/schedule.html.twig +++ b/templates/fediplan/schedule.html.twig @@ -479,8 +479,10 @@ $('#poll_switch').click(function (e) { if($('#poll_container').hasClass("d-none") ){ $('#poll_container').removeClass("d-none"); + $('#compose_attach_poll').val(1); }else{ $('#poll_container').addClass("d-none"); + $('#compose_attach_poll').val(0); } }); var $collectionHolder;