{% import "_includes/forms" as forms %} {{ forms.textField({ first: true, label: "Name"|t('app'), instructions: "What this tax category will be called in the CP."|t('commerce'), id: 'name', name: 'name', value: taxCategory is defined ? taxCategory.name, errors: taxCategory is defined ? taxCategory.getErrors('name'), autofocus: true, required: true, translatable: true }) }} {{ forms.textField({ label: "Handle"|t('app'), 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('app'), id: 'description', name: 'description', value: taxCategory is defined ? taxCategory.description, errors: taxCategory is defined ? taxCategory.getErrors('description') }) }} {% set productTypeInputs %} {% for productType in productTypes %} {{ forms.checkboxField({ label: productType.name, name: 'productTypes['~productType.id~']', value: productType.id, id: 'productType:'~productType.id, checked: taxCategory is defined ? (productType.id in taxCategory.productTypeIds) : false, }) }} {% endfor %} {% endset %} {{ forms.field({ label: "Available to Product Types"|t('commerce'), instructions: "Which product types should this category be available to?"|t('commerce') }, productTypeInputs) }} {% 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') }) }} {% 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 %}