fix(classifieds): scope Quill submit handler to actual form
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

document.querySelector('form') was matching the company switcher form
in the navbar, not the classifieds form. Quill content was therefore
never synced into the hidden description textarea, server saw it empty
and rejected the submit with a misleading 'fill all fields' error.

Added id='classifiedForm' to both new.html and edit.html and switched
selectors to getElementById.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-14 13:42:56 +02:00
parent 9d5905e689
commit e1a16e2542
2 changed files with 4 additions and 4 deletions

View File

@ -82,7 +82,7 @@
</div>
<div class="form-card">
<form method="POST" action="{{ url_for('classifieds.classifieds_edit', classified_id=classified.id) }}" enctype="multipart/form-data">
<form id="classifiedForm" method="POST" action="{{ url_for('classifieds.classifieds_edit', classified_id=classified.id) }}" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="form-group">
@ -193,7 +193,7 @@ quill.root.innerHTML = {{ classified.description|tojson }};
(function() {
var qc = document.getElementById('quill-editor');
quill.on('text-change', function() { qc && qc.classList.remove('field-error'); });
document.querySelector('form').addEventListener('submit', function(e) {
document.getElementById('classifiedForm').addEventListener('submit', function(e) {
var html = quill.root.innerHTML;
var empty = (html === '<p><br></p>' || quill.getText().trim() === '');
if (empty) {

View File

@ -270,7 +270,7 @@
Ogłoszenie będzie widoczne przez 30 dni. Po tym czasie wygaśnie automatycznie.
</div>
<form method="POST" action="{{ url_for('classifieds.classifieds_new') }}" enctype="multipart/form-data">
<form id="classifiedForm" method="POST" action="{{ url_for('classifieds.classifieds_new') }}" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
{% if has_multiple_companies %}
@ -393,7 +393,7 @@ var quill = new Quill('#quill-editor', {
// Clear error highlight as soon as user starts typing
quill.on('text-change', function() { qc && qc.classList.remove('field-error'); });
document.querySelector('form').addEventListener('submit', function(e) {
document.getElementById('classifiedForm').addEventListener('submit', function(e) {
var html = quill.root.innerHTML;
var empty = (html === '<p><br></p>' || quill.getText().trim() === '');
if (empty) {