# ASHT Nomination Validation Module

This module provides server-side validation for the ASHT Hall of Fame nomination form to ensure all eligibility requirements are met based on whether the nominee is a founding member or not.

## How the Solution Works

The nomination form has complex eligibility requirements that implement XOR-like logic:

- **For Founding Members**: Only requires the nominator to be a current ASHT member in good standing
- **For Non-Founding Members**: Requires the nominator to be a current ASHT member AND all four additional criteria must be met:
  - Nominee must be an ASHT member in good standing (or deceased former member)
  - Nominee must be a Certified Hand Therapist
  - Nominee must have been a previous volunteer within a committee or division
  - Nominee must be a previous award winner

This module implements this logic through:
1. **Client-side conditional logic** (configured in the webform source) that enables/disables the submit button
2. **Server-side validation** (via the WebformHandler) that ensures requirements can't be bypassed

## Installation Instructions

### Step 1: Remove Existing Submit Button Conditions

**Important**: Before implementing this solution, you must remove any existing conditional logic on the submit button:

1. In the webform UI, go to the "Build" tab
2. Find your submit button (likely under "Actions")
3. Click "Edit" on the submit button
4. Go to the "Conditions" tab
5. **Delete/remove all conditional logic** for the enabled state
6. Save the submit button

### Step 2: Add Submit Button States via Webform Source

In the webform UI, click "Source" and find the `actions:` section (usually near the bottom). Replace it with:

```yaml
actions:
  '#type': webform_actions
  '#title': 'Submit button(s)'
  '#submit__label': Submit
  '#states':
    disabled:
      - ':input[name="is_the_nominator_a_current_member_of_asht_in_good_standing_for_a"]':
          '!value': 'Yes'
      - or
      - ':input[name="is_the_nominee_a_founding_member_"]':
          '!checked': true
      - or
      - ':input[name="is_the_nominee_a_founding_member_"]':
          value: 'No'
        ':input[name="is_the_nominee_currently_an_asht_member_in_good_standing_or_were"]':
          '!value': 'Yes'
      - or
      - ':input[name="is_the_nominee_a_founding_member_"]':
          value: 'No'
        ':input[name="is_the_nominee_a_certified_hand_therapist_"]':
          '!value': 'Yes'
      - or
      - ':input[name="is_the_nominee_a_previous_volunteer_within_a_committee_or_divisi"]':
          value: 'No'
        ':input[name="is_the_nominee_a_previous_winner_of_the_nathalie_barr_lectureshi"]':
          '!value': 'Yes'
      - or
      - ':input[name="is_the_nominee_a_founding_member_"]':
          value: 'No'
        ':input[name="is_the_nominee_a_previous_winner_of_the_nathalie_barr_lectureshi"]':
          '!value': 'Yes'
```

Save the source changes.

### Step 3: Enable the Module

1. Navigate to Extend (admin/modules)
2. Find "ASHT Nomination Validation" under the ASHT package
3. Check the box and click "Install"

### Step 4: Add the Validation Handler to Your Webform

In the webform UI:
1. Go to Settings → Emails/Handlers
2. Click "Add handler"
3. Select "ASHT Validation"
4. Save

## Testing

After installation, test the form to ensure:

1. **Submit button is disabled** when nominator is not an ASHT member
2. **Submit button is enabled** when:
   - Nominator = Yes AND Founding Member = Yes
   - Nominator = Yes AND Founding Member = No AND all four additional fields = Yes
3. **Submit button is disabled** when Founding Member = No and any of the four additional fields are No
4. **Server-side validation** prevents submission even if client-side validation is bypassed

## Technical Details

- The client-side states API provides immediate visual feedback to users
- The server-side WebformHandler ensures security by validating all requirements on form submission
- Both validations use identical logic to ensure consistency

## Troubleshooting

If the submit button behavior isn't working correctly:
1. Verify all existing conditional logic was removed from the submit button
2. Check that field machine names in the YAML match exactly (they are case-sensitive)
3. Clear Drupal's cache after making changes
4. Check the browser console for any JavaScript errors
