Month Select
month_select outputs an HTML <select> containing months 01 through 12.
Month labels are localized through ExpressionEngine language lines (January, February, etc.), while option values remain zero-padded numeric month keys.
See also:
Parameters
selected
Selected month value.
Expected format is 01..12. If missing or invalid, the current month (date('m')) is selected.
selected="{customer_expiration_month}"
name
HTML name attribute for the generated <select>.
Default: expiration_month.
name="expiration_month"
extra
Raw extra attributes appended to the <select> output.
extra='rel="my_attr" title="my title"'
onchange
Optional JavaScript to run when the value changes.
onchange="your_custom_javascript()"
class
CSS class attribute for the generated <select>.
class="month-select"
id
CSS/DOM id attribute for the generated <select>.
id="expiration_month"
Output
Returns a complete <select> element with:
- values
01..12 - localized month-name labels
- selected month based on
selected(or current month fallback) - optional HTML attributes from
id,class,onchange, andextra
Behavior and Constraints
- This is an immediate-execution single tag.
- Month option values are fixed to
01..12. - Labels come from language lines, so displayed month names depend on active language.
- If
selectedis not provided or is not one of01..12, the current month is selected. - This tag only renders the month
<select>; it does not validate or save submitted values by itself.
Examples
Default output:
{exp:cartthrob:month_select}
Use with selected value and custom input name:
{exp:cartthrob:month_select selected="{customer_expiration_month}" name="expiration_month"}
Include HTML attributes:
{exp:cartthrob:month_select
name="expiration_month"
id="expiration_month"
class="form-control"
onchange="updateCardPreview()"
extra='data-test=\"exp-month\"'}