Skip to content
  1. Extras
  2. FetchIt
  3. FetchIt Snippet

FetchIt Snippet

This snippet submits a form using the Fetch API and runs the snippet specified in the snippet parameter by passing parameters to it. By default it calls the FormIt snippet, but you can use your own. It also loads the server response processing script on the frontend.

Snippet properties

PropertyDefault value
formtpl.FetchIt.exampleChunk with the form to be processed
snippetFormItRunable snippet for form processing
actionUrl[[+assetsUrl]]action.phpThe address of the connector to which the form is sent
clearFieldsOnSuccess1This parameter is responsible for clearing the form data after a successful response

All other parameters you specify when calling FetchIt will be passed to the snippet specified in the snippet parameter.

Example

modx
[[!FetchIt?
  &form=`myForm.tpl`
  &hooks=`email`
  &emailSubject=`Email subject`
  &emailTo=`info@domain.com`
  &validate=`name:required,email:required`
  &validationErrorMessage=`This form has errors!`
  &successMessage=`The form has been submitted successfully`
]]
fenom
{'!FetchIt' | snippet : [
  'form' => 'myForm.tpl',
  'hooks' => 'email',
  'emailSubject' => 'Email subject',
  'emailTo' => 'info@domain.com',
  'validate' => 'name:required,email:required',
  'validationErrorMessage' => 'This form has errors!',
  'successMessage' => 'The form has been submitted successfully',
]}