# Form template overrides

Customize ImmoSync shortcode forms from your WordPress theme without editing the plugin.

You can override:

- the **contact** form (`[wpis-form-contact]`)
- the **contact extended** form (`[wpis-form-contact type="extended"]`)
- the **estate** form (`[wpis-form-estate]`)
- the **evaluation** form (`[wpis-form-evaluation]`)

## Setup

In your active theme (or child theme), create:

```
immosync/form/
```

Then add only the files you want to customize:

| Theme file | Overrides | Shortcode |
|---|---|---|
| `immosync/form/contact.html` | `contact.default.form.html` | `[wpis-form-contact]` |
| `immosync/form/contact-extended.html` | `contact.extended.form.html` | `[wpis-form-contact type="extended"]` |
| `immosync/form/estate.html` | `estate.default.form.html` | `[wpis-form-estate]` |
| `immosync/form/evaluation.html` | `evaluation.default.form.html` | `[wpis-form-evaluation]` |

Example:

```
your-theme/
  immosync/
    form/
      contact.html
      contact-extended.html
      estate.html
      evaluation.html
```

## Resolution order

1. Child theme (`get_stylesheet_directory()`)
2. Parent theme (`get_template_directory()`), if different
3. Plugin default under `plugin/templates/form/`

If a file is missing in the theme, the plugin default is used. You can override one form and leave the others alone.

## How to start

1. Copy the matching plugin file into your theme path (rename as in the table above).
2. Edit the copy.
3. Reload a page that uses the shortcode to verify the markup.

Plugin sources to copy from:

- `plugin/templates/form/contact.default.form.html` → `immosync/form/contact.html`
- `plugin/templates/form/contact.extended.form.html` → `immosync/form/contact-extended.html`
- `plugin/templates/form/estate.default.form.html` → `immosync/form/estate.html`
- `plugin/templates/form/evaluation.default.form.html` → `immosync/form/evaluation.html`

## Placeholders

Translated labels and messages use Mustache-style tags replaced by the shortcode, for example:

- `{{ form.gender.label }}`, `{{ form.firstname.label }}`, `{{ form.lastname.label }}`
- `{{ form.email.label }}`, `{{ form.phone.label }}`, `{{ form.message.label }}`
- `{{ form.policy.label }}`, `{{ form.policy.value }}`, `{{ form.submit.value }}`
- `{{ message.success }}`, `{{ message.processing }}`
- `{{ error.single }}`, `{{ error.multiple }}`

Address fields (extended contact / evaluation) also use `{{ form.addressStreet.label }}`, `addressNumber`, `addressBox`, `addressZip`, `addressCity`.

### Estate form only

These tokens are replaced by the shortcode:

- `%estateId%` — from the `estate-id` attribute when set, otherwise from the current estate page
- `%postId%` — current post ID

Keep them in your override if the form must still target the correct estate.

## Limits

- Shortcode attributes still apply (`style`, `submit`, `type`, `estate-id`).
- `type="extended"` loads `contact-extended.html` when present; otherwise the plugin extended template.
- Form submission JS and API behavior are unchanged by these HTML overrides.
- **Important:** The form tag and each form input must keep its original `id` attribute unchanged so plugin JS can find and process the fields correctly.
- Filter hook for advanced use: `wpis_form_template_path`.
