Skip to content

t509: fix: template_selection validation never fires — field ID maps to wrong rule key #799

@superdav42

Description

@superdav42

What

The template_selection checkout field submits its value as template_id in POST data, but the validation rule lookup used field['id'] (i.e. template_selection) directly. Since no validation rule exists under the key template_selection, the required check never fires — allowing checkout to proceed with no template selected.

Additionally, Rakit's required rule treats integer 0 as "present", so even a correctly-keyed rule would accept template_id=0. The fix adds min:1 for template_id specifically.

Also fixes the validation error label from "Template ID" → "Template Selection" for better UX.

Changes (uncommitted in worktree bugfix/template-validation)

  • EDIT: inc/checkout/class-checkout.php — add $field_to_rule_key map, use mapped key for rule lookup, add min:1 for template_id, fix label string

Acceptance Criteria

  • Checkout with a required template selection field and no template chosen shows a validation error
  • template_id=0 is rejected when template_selection field has required attribute
  • Validation error reads "Template Selection" not "Template ID"

Verification

# Manual: set a checkout form with required template_selection, submit without selecting
# Expected: validation error shown reading "Template Selection"

aidevops.sh v3.6.244 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 3m and 10,602 tokens on this as a headless worker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingorigin:workerAuto-created by pulse labelless backfill (t2112)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions