{% import "_includes/forms" as forms %} {{ forms.textField({ first: true, label: "Name"|t('commerce'), instructions: "What this tax category will be called in the control panel."|t('commerce'), id: 'name', name: 'name', value: taxCategory is defined ? taxCategory.name, errors: taxCategory is defined ? taxCategory.getErrors('name'), autofocus: true, required: true }) }} {{ forms.textField({ label: "Handle"|t('commerce'), instructions: "How you’ll refer to this tax category in the templates."|t('commerce'), id: 'handle', class: 'code', name: 'handle', required: true, value: taxCategory is defined ? taxCategory.handle, errors: taxCategory is defined ? taxCategory.getErrors('handle') }) }} {{ forms.textField({ label: "Description"|t('commerce'), id: 'description', name: 'description', value: taxCategory is defined ? taxCategory.description, errors: taxCategory is defined ? taxCategory.getErrors('description') }) }} {{ forms.checkboxSelectField({ label: "Available to Product Types"|t('commerce'), instructions: "Which product types should this category be available to?"|t('commerce'), id: 'productTypes', name: 'productTypes', options: productTypesOptions, values: taxCategory is defined ? taxCategory.productTypeIds : [], showAllOption: false, }) }} {% set defaultInput %} {{ forms.checkboxField({ label: "New products default to the first tax category available to them. If none are available, this category will be used."|t('commerce'), id: 'default', name: 'default', value: 1, checked: taxCategory is defined ? taxCategory.default, errors: taxCategory is defined ? taxCategory.getErrors('default'), disabled: (isDefaultAndOnlyCategory is defined and isDefaultAndOnlyCategory) or (taxCategory is defined and taxCategory.id and taxCategory.default) }) }} {% if (isDefaultAndOnlyCategory is defined and isDefaultAndOnlyCategory) or (taxCategory is defined and taxCategory.id and taxCategory.default) %} {{ hiddenInput('default', 1) }} {% endif %} {% endset %} {{ forms.field({ label: "Default Category"|t('commerce'), }, defaultInput) }} {% if taxCategory is not defined or not taxCategory.handle %} {% set nameId = 'name'|namespaceInputId|e('js') %} {% set handleId = 'handle'|namespaceInputId|e('js') %} {% js %} new Craft.HandleGenerator('#{{ nameId }}', '#{{ handleId }}'); {% endjs %} {% endif %}