# API - Form Components

Shared form helpers for `FormComponentsBase` and theme overrides.

## Base API

`src/core/templates/components-form-base.template.php`

| Method | Inputs | Description |
|---|---|---|
| `startForm` | `$action`, `$method=post`, `$enctype=null`, `$attributes=null`, `$additionalClasses=`, `$plain=false` | Open form |
| `endForm` | `$plain=false` | Close form |
| `startEmptyRow` | none | Empty hook |
| `endEmptyRow` | none | Empty hook |
| `showSeparator` | none | Blank separator |
| `showTextRaw` | `$text` | Raw text row |
| `showAlert` | `$level`, `$textRaw` | Bootstrap alert |
| `showInputText` | `$name`, `$value`, `$label`, `$placeholder=`, `$required=false`, `$attributes=null`, `$additionalInfo=null`, `$type=text`, `$plain=false` | Text input |
| `showInputTextArea` | `$name`, `$value`, `$label`, `$placeholder=`, `$required=false`, `$attributes=null`, `$additionalInfo=null`, `$type=text`, `$plain=false` | Textarea |
| `showSecurityCode` | `$additionalInfo`, `$name=SecurityCode`, `$attributes=null` | Captcha field |
| `showButton` | `$name`, `$value`, `$label`, `$attributes=null`, `$type=submit`, `$plain=false` | Primary button |
| `showRadioButton` | `$name`, `$value`, `$label`, `$checked=false`, `$attributes=null`, `$plain=false` | Radio option |
| `showCheckbox` | `$name`, `$value`, `$label`, `$required=false`, `$checked=false`, `$additionalInfo=null`, `$attributes=null`, `$plain=false` | Checkbox input |
| `showRadioButtonList` | `$name`, `$label`, `$items`, `$value`, `$additionalInfo=null`, `$attributes=null`, `$plain=false` | Radio list |
| `showInputPassword` | `$name`, `$value`, `$label`, `$placeholder=`, `$required=false`, `$attributes=null`, `$additionalInfo=null`, `$plain=false` | Password input |
| `showInputNumber` | `$name`, `$value`, `$label`, `$placeholder=`, `$required=false`, `$attributes=null`, `$additionalInfo=null`, `$plain=false` | Number input |
| `showSelect` | `$name`, `$label`, `$options`, `$selectedValue=null`, `$required=false`, `$attributes=null`, `$additionalInfo=null`, `$plain=false` | Select input |
| `showText` | `$text` | Translated text |
| `getProductImageURL` | `$product` | Image path |
| `showProduct` | `$product`, `$buyAccount`, `$showQuantityInput=true` | Product form |
| `showLanguageOptions` | `$name`, `$label`, `$languageList`, `$selectedLanguageKey`, `$additionalInfo=null`, `$plain=false` | Language radios |
| `showSuccessError` | `&$success`, `&$error`, `&$warning=null` | Status alerts |
| `showCaptcha` | none | Captcha image |
| `showToken` | none | Hidden token |
| `printAttributes` | `$attributes` | Echo attributes |

## Notes

| Method | Note |
|---|---|
| `showInputPassword` | Proxies `showInputText` |
| `showInputNumber` | Proxies `showInputText` |
| `showCheckbox` | Forces `type="checkbox"` |
| `showSecurityCode` | Skips when `CAPTCHA` is false |
| `showToken` | Uses `getToken()` |
| `printAttributes` | Echoes `key="value"` |
| `showProduct` | Themes can customize output (e.g., `.product__image--default`) |

## Theme overrides

- `src/templates/{theme}/components-form.template.php`
```php
class FormComponents extends FormComponentsBase
{
  public static function <MethodToRewrite>(<params>)
  {
    <rewroteCode>
  }
}
```

- Themes can customize `showProduct` markup (e.g., adding `.product__image--default` when the product image is empty or `default.svg`).
- Themes can constrain table column widths such as `.cart-payment-methods` first column (`th:first-child`, `td:first-child`: `width: 175px; max-width: 175px;`).