
FetchIt
Lightweight AJAX form submission in MODX via the Fetch API on top of FormIt or a custom snippet


Pico.css styles invalid fields via aria-invalid. FetchIt sets this attribute automatically. You usually do not need an invalid class in settings for Pico.
<form>
<label>
Name
<input type="text" name="name">
</label>
<label>
Email
<input type="email" name="email">
</label>
<button type="submit">Submit</button>
</form>Steps:
data-error for error text.[data-success] and [data-validation-error] for AJAX.Информация
Set action to the page URL.
<form>
<form action="[[~[[*id]]]]" method="post">
<label>
Name
<input type="text" name="name">
<input type="text" name="name" value="[[+fi.name]]">
<small data-error="name">[[+fi.error.name]]</small>
</label>
<label>
Email
<input type="email" name="email">
<input type="email" name="email" value="[[+fi.email]]">
<small data-error="email">[[+fi.error.email]]</small>
</label>
<div role="alert" data-success style="display: none;"></div>
<div role="alert" data-validation-error style="display: none;"></div>
<button type="submit">Submit</button>
</form><form>
<form action="{$_modx->resource.id | url}" method="post">
<label>
Name
<input type="text" name="name">
<input type="text" name="name" value="{$_modx->getPlaceholder('fi.name')}">
<small data-error="name">{$_modx->getPlaceholder('fi.error.name')}</small>
</label>
<label>
Email
<input type="email" name="email">
<input type="email" name="email" value="{$_modx->getPlaceholder('fi.email')}">
<small data-error="email">{$_modx->getPlaceholder('fi.error.email')}</small>
</label>
<div role="alert" data-success style="display: none;"></div>
<div role="alert" data-validation-error style="display: none;"></div>
<button type="submit">Submit</button>
</form>