jevo / jforms
Secure Blade form submissions and responses for Evolution CMS
Requires
- php: ^8.3
- evolution-cms/evolution: ^3.5.7
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Secure AJAX form submission and response storage for Evolution CMS 3. Build forms with ordinary Blade/HTML, define validation rules in trusted server-side configuration or controller code, and let jForms validate and store responses as JSON.
Usage guides: English · Українська
Requirements
- Evolution CMS
^3.5.7 - PHP
^8.3 - Composer
Installation
Run from the Evolution CMS core/ directory:
php artisan package:installrequire jevo/jforms "^1.0"
php artisan migrate
One migration creates the jforms_responses table and one-time-token index. On existing installations, it adds any missing token schema and removes the obsolete idempotency column without deleting saved responses. The manager module Form responses / Відповіді форм lists forms with responses and lets authorized manager users browse and delete submissions. When Evo UI is installed, the module uses its manager theme and components; otherwise, it uses the built-in Blade interface.
To publish the default configuration to core/custom/config/jevo/jforms.php:
php artisan vendor:publish --tag=jforms-config php artisan vendor:publish --tag=jforms-assets
File uploads are not supported.
Controller
Register a POST route inside the web middleware group so CSRF protection applies. Keep form names and validation rules in trusted PHP code; never accept them from the request.
use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use Jevo\JForms\SubmissionService; Route::middleware('web')->post('/appointment', function (Request $request, SubmissionService $jForms) { $result = $jForms->submitDefinition( 'appointment', 'Appointment request', $request->all(), [ 'phone' => ['required', 'string', 'max:40'], 'email' => ['nullable', 'email:rfc', 'max:190'], 'child_name' => ['nullable', 'string', 'max:120'], ], (string) $request->ip(), [ 'honeypot' => 'website', 'rate_limit' => ['attempts' => 10, 'decay_seconds' => 60], 'max_payload_bytes' => 16384, 'success_message' => 'Thank you. We will contact you soon.', ] ); return response()->json(['ok' => true] + $result, 201); });
submitDefinition() validates only fields listed in the server rules, discards other request keys, rate-limits submissions by IP and form (10 attempts per minute by default), requires an empty honeypot field, caps the payload at 16 KB, and CSRF is enforced by the web middleware. These measures reduce automated abuse without CAPTCHA; they do not guarantee that every bot is blocked.
Blade form and AJAX
Register the form in core/custom/config/jevo/jforms.php, then use the package routes. The package adds its JavaScript tag automatically when it compiles a Blade template containing data-jforms-form:
<form id="appointment-form" data-jforms-form data-jforms-token-url="{{ route('jForms.token', ['form' => 'appointment']) }}" action="{{ route('jForms.submit', ['form' => 'appointment']) }}" method="post"> @csrf <input type="hidden" name="_jforms_token" value="{{ app(\Jevo\JForms\SubmissionService::class)->issueToken('appointment') }}"> <input type="tel" name="phone" required> <input type="email" name="email"> <input type="text" name="child_name"> <input type="text" name="website" tabindex="-1" autocomplete="off" aria-hidden="true" class="d-none"> <button type="submit">Send</button> <p data-jforms-status role="status" aria-live="polite"></p> </form> <script src="/theme/dist/js/forms.min.js" defer></script>
The jForms AJAX handler is included in the package at resources/js/jforms.js with a minified build at resources/js/jforms.min.js. Publish the asset with php artisan vendor:publish --tag=jforms-assets; the package injects /assets/modules/jforms/jforms.min.js into templates containing the form marker. It uses native browser APIs and does not depend on the theme bundle or jQuery. Before each submit, it fetches a fresh form token; the server validates its signature, expiry, and one-time use.
For custom toast or modal notifications, listen for the bubbling jforms:success and jforms:error events on document. Their event.detail.message contains the displayed message; errors also include the HTTP code in event.detail.status. Examples for SweetAlert2 and other libraries are in the usage guide.
License
GNU General Public License v3.0 or later. See LICENSE.
Українська
Докладні інструкції: українською · English
jForms — пакет для AJAX-відправлення Blade-форм і збереження відповідей у JSON для Evolution CMS 3. Розмітку форми пишіть звичайним Blade/HTML, правила перевірки задавайте у довіреній серверній конфігурації або коді контролера.
Вимоги
- Evolution CMS
^3.5.7 - PHP
^8.3 - Composer
Встановлення
Виконайте команди з каталогу core/ Evolution CMS:
php artisan package:installrequire jevo/jforms "^1.0"
php artisan migrate
Міграція створює таблицю jforms_responses. У менеджері з’явиться модуль «Відповіді форм» / “Form responses”. Він показує форми з відповідями, дозволяє переглядати їх і видаляти відповідно до прав менеджера. Якщо встановлено Evo UI, модуль використовує його тему й компоненти; без Evo UI працює вбудований Blade-інтерфейс.
Щоб опублікувати стандартну конфігурацію в core/custom/config/jevo/jforms.php:
php artisan vendor:publish --tag=jforms-config
Завантаження файлів поки не підтримується.
Контролер і Blade
Зареєструйте POST-маршрут у middleware-групі web, щоб діяла CSRF-перевірка. Назву форми й правила валідації задавайте в довіреному PHP-коді сервера, а не в запиті браузера. Приклади контролера та Blade/AJAX-форми наведені в англійській секції вище.
submitDefinition() перевіряє лише поля, задані сервером, відкидає інші ключі запиту, обмежує частоту надсилань за IP та формою (за замовчуванням 10 спроб за хвилину), вимагає порожнє поле honeypot і обмежує запит до 16 КБ. CSRF перевіряється middleware-групою web. Ці перевірки зменшують автоматизований спам без CAPTCHA, але не гарантують блокування всіх ботів.
Ліцензія
GNU General Public License версії 3 або новішої. Повний текст — у файлі LICENSE.