diff --git a/exampleSite/content/fragments/contact/docs.md b/exampleSite/content/fragments/contact/docs.md index 4358d4bb..bcb72f89 100644 --- a/exampleSite/content/fragments/contact/docs.md +++ b/exampleSite/content/fragments/contact/docs.md @@ -170,3 +170,32 @@ Any other value for the `name` variable in the `fields.hidden` object will have Value of the hidden field. This field will be overridden if `name` is set to `site` or `page`. [Global variables]({{< ref "global-variables" >}}) are documented as well and have been omitted from this page. + +#### fields.custom +*type: array of objects* + +This array is used to define custom inputs. These inputs are displayed in addition to the default inputs of the contact form. + +##### fields.custom.name +*type: string* + +##### fields.custom.text +*type: string* + +##### fields.custom.error +*type: string* +*default: i18n contact.defaultError* + +##### fields.custom.required +*type: boolean* + +##### fields.custom.validation +*type: boolean, string* +*accepted values: email, regex* + +Applies validation rules to the input. If not set or set to false, no validation will be applied. + +##### fields.custom.validation_regex +*type: string* + +In case `fields.custom.validation` is set to `regex`, you can specify the regex here. diff --git a/i18n/en.yaml b/i18n/en.yaml index 617805b9..d2cf8536 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -9,6 +9,8 @@ translation: "Read more..." # Contact Form +- id: contact.defaultError + translation: 'Please fill the field' - id: contact.defaultNameError translation: "Please enter your name" - id: contact.defaultEmailError diff --git a/layouts/partials/fragments/contact.html b/layouts/partials/fragments/contact.html index 9ff8c3c1..feefc86f 100644 --- a/layouts/partials/fragments/contact.html +++ b/layouts/partials/fragments/contact.html @@ -68,6 +68,45 @@
{{- end }} + {{- range (.Params.fields.custom | default slice) }} + {{- $field := . }} +