mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-12 02:39:51 +00:00
fix validation when comment content is empty
This commit is contained in:
parent
03007370bc
commit
b3e65f0733
@ -235,6 +235,8 @@ class NotificationController extends AbstractController
|
|||||||
'id' => $notification->getId(),
|
'id' => $notification->getId(),
|
||||||
'_fragment' => 'comment-' . $commentId,
|
'_fragment' => 'comment-' . $commentId,
|
||||||
]);
|
]);
|
||||||
|
} elseif ($editedCommentForm->isSubmitted() && !$editedCommentForm->isValid()) {
|
||||||
|
$this->addFlash('error', $this->translator->trans('This form contains errors'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,6 +258,8 @@ class NotificationController extends AbstractController
|
|||||||
return $this->redirectToRoute('chill_main_notification_show', [
|
return $this->redirectToRoute('chill_main_notification_show', [
|
||||||
'id' => $notification->getId(),
|
'id' => $notification->getId(),
|
||||||
]);
|
]);
|
||||||
|
} elseif ($appendCommentForm->isSubmitted() && !$appendCommentForm->isValid()) {
|
||||||
|
$this->addFlash('error', $this->translator->trans('This form contains errors'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ use DateTimeInterface;
|
|||||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||||
use Doctrine\ORM\Event\PreFlushEventArgs;
|
use Doctrine\ORM\Event\PreFlushEventArgs;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
@ -28,6 +29,7 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
|
* @Assert\NotBlank(message="notification.Comment content might not be blank")
|
||||||
*/
|
*/
|
||||||
private string $content = '';
|
private string $content = '';
|
||||||
|
|
||||||
@ -136,9 +138,9 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
|
|||||||
$this->recentlyPersisted = true;
|
$this->recentlyPersisted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContent(string $content): self
|
public function setContent(?string $content): self
|
||||||
{
|
{
|
||||||
$this->content = $content;
|
$this->content = (string) $content;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
<div class="notification-comment-list my-5">
|
<div class="notification-comment-list my-5">
|
||||||
<h2 class="chill-blue">{{ 'notification.comments_list'|trans }}</h2>
|
<h2 class="chill-blue">{{ 'notification.comments_list'|trans }}</h2>
|
||||||
|
|
||||||
{% if notification.comments|length > 0 %}
|
{% if notification.comments|length > 0 %}
|
||||||
<div class="flex-table">
|
<div class="flex-table">
|
||||||
{% for comment in notification.comments %}
|
{% for comment in notification.comments %}
|
||||||
|
|
||||||
{% if editedCommentForm is null or editedCommentId != comment.id %}
|
{% if editedCommentForm is null or editedCommentId != comment.id %}
|
||||||
{{ m.show_comment(comment, {
|
{{ m.show_comment(comment, {
|
||||||
'recordAction': _self.recordAction(comment)
|
'recordAction': _self.recordAction(comment)
|
||||||
@ -28,10 +28,11 @@
|
|||||||
<div class="item-bloc">
|
<div class="item-bloc">
|
||||||
<div class="item-row row">
|
<div class="item-row row">
|
||||||
<a id="comment-{{ comment.id }}"></a>
|
<a id="comment-{{ comment.id }}"></a>
|
||||||
|
|
||||||
{{ form_start(editedCommentForm) }}
|
{{ form_start(editedCommentForm) }}
|
||||||
{{ form_errors(editedCommentForm) }}
|
{{ form_errors(editedCommentForm) }}
|
||||||
{{ form_widget(editedCommentForm.content) }}
|
{{ form_widget(editedCommentForm.content) }}
|
||||||
|
{{ form_errors(editedCommentForm.content) }}
|
||||||
<input type="hidden" name="form" value="edit" />
|
<input type="hidden" name="form" value="edit" />
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li class="cancel">
|
<li class="cancel">
|
||||||
@ -46,24 +47,25 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{ form_end(editedCommentForm) }}
|
{{ form_end(editedCommentForm) }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="chill-no-data-statement">{{ 'No comments'|trans }}</span>
|
<span class="chill-no-data-statement">{{ 'No comments'|trans }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if appendCommentForm is not null %}
|
{% if appendCommentForm is not null %}
|
||||||
<div class="new-comment my-5">
|
<div class="new-comment my-5">
|
||||||
<h2 class="chill-blue mb-4">{{ 'Write a new comment'|trans }}</h2>
|
<h2 class="chill-blue mb-4">{{ 'Write a new comment'|trans }}</h2>
|
||||||
|
|
||||||
{{ form_start(appendCommentForm) }}
|
{{ form_start(appendCommentForm) }}
|
||||||
{{ form_errors(appendCommentForm) }}
|
{{ form_errors(appendCommentForm) }}
|
||||||
{{ form_widget(appendCommentForm.content) }}
|
{{ form_widget(appendCommentForm.content) }}
|
||||||
|
{{ form_errors(appendCommentForm.content) }}
|
||||||
<input type="hidden" name="form" value="append" />
|
<input type="hidden" name="form" value="append" />
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
@ -71,7 +73,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{ form_end(appendCommentForm) }}
|
{{ form_end(appendCommentForm) }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -27,4 +27,4 @@ address:
|
|||||||
notification:
|
notification:
|
||||||
At least one addressee: Indiquez au moins un destinataire
|
At least one addressee: Indiquez au moins un destinataire
|
||||||
Title must be defined: Un titre doit être indiqué
|
Title must be defined: Un titre doit être indiqué
|
||||||
|
Comment content might not be blank: Le commentaire ne peut pas être vide
|
||||||
|
Loading…
x
Reference in New Issue
Block a user