# Form Connector

Connect WordPress forms to CareHQ CRM with intelligent field mapping and conditional routing.

## Description

Form Connector seamlessly integrates your WordPress contact forms with CareHQ CRM. It supports multiple form plugins and provides a visual workflow builder for configuring how form submissions are routed to different CareHQ locations.

### Supported Form Plugins

- **Gravity Forms**
- **Forminator**
- **WPForms**
- **Fluent Forms**
- **Contact Form 7**

### Key Features

- **Visual Workflow Builder** - See exactly how your form data flows to CareHQ
- **Smart Field Mapping** - Map form fields to CareHQ contact fields
- **Conditional Routing** - Route submissions to different locations based on form field values
- **UTM Tracking** - Automatic capture of marketing attribution data
- **Submission Logging** - Track all form submissions with detailed logs
- **Phone Validation** - Automatic UK phone number validation and formatting
- **Health Dashboard** - Monitor API connectivity and system status

## Requirements

- PHP 8.0 or higher
- WordPress 6.0 or higher
- A valid Form Connector license
- CareHQ CRM account with API credentials

## Installation

1. Upload the `form-connector` folder to `/wp-content/plugins/`
2. Activate the plugin through the WordPress Plugins menu
3. Navigate to **Form Connector** in the admin menu
4. Enter your license key in the License tab
5. Configure your CareHQ API credentials
6. Set up form mappings for your forms

## Configuration

### CareHQ API Setup

1. Log into your CareHQ account
2. Navigate to Settings → API
3. Create API credentials (Account ID, API Key, API Secret)
4. Enter these credentials in Form Connector → CareHQ Settings

### Form Mapping

1. Go to Form Connector → Mappings
2. Select a form from the dropdown
3. Map your form fields to CareHQ fields
4. Configure conditional routing if needed
5. Enable the integration and save

## Development

### Prerequisites

- Node.js 18+
- pnpm
- Composer

### Setup

```sh
# Install PHP dependencies
composer install

# Install JS dependencies
pnpm install

# Development mode
pnpm dev

# Production build
pnpm build
```

## Changelog

### 3.0.0

- Complete rebuild with modern Svelte 5 frontend
- New visual workflow builder
- Improved conditional routing with duplicate detection
- Enhanced error handling and logging
- Phone number validation with libphonenumber

## License

GPL v2 or later - see [LICENSE](LICENSE) file for details.

## Support

For support, please visit [formconnector.co.uk](https://formconnector.co.uk)
