@spree/docs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +54 -0
  2. package/dist/api-reference/platform/authentication.md +38 -0
  3. package/dist/api-reference/store-api/authentication.md +188 -0
  4. package/dist/api-reference/store-api/errors.md +277 -0
  5. package/dist/api-reference/store-api/idempotency.md +129 -0
  6. package/dist/api-reference/store-api/introduction.md +34 -0
  7. package/dist/api-reference/store-api/localization.md +279 -0
  8. package/dist/api-reference/store-api/metadata.md +160 -0
  9. package/dist/api-reference/store-api/monetary-amounts.md +65 -0
  10. package/dist/api-reference/store-api/querying.md +399 -0
  11. package/dist/api-reference/store-api/rate-limitting.md +103 -0
  12. package/dist/api-reference/store-api/relations.md +185 -0
  13. package/dist/api-reference/storefront/authentication.md +88 -0
  14. package/dist/api-reference/tutorials/adyen-integration-guide-for-android.md +165 -0
  15. package/dist/api-reference/tutorials/adyen-integration-guide-for-ios.md +194 -0
  16. package/dist/api-reference/tutorials/quick-checkout-with-stripe.md +248 -0
  17. package/dist/api-reference/v2/fetching-multiple-resources.md +26 -0
  18. package/dist/api-reference/v2/filtering-and-sorting.md +53 -0
  19. package/dist/api-reference/v2/introduction.md +22 -0
  20. package/dist/api-reference/v2/pagination.md +37 -0
  21. package/dist/api-reference/webhooks-events.md +883 -0
  22. package/dist/developer/admin/admin.md +205 -0
  23. package/dist/developer/admin/authentication.md +59 -0
  24. package/dist/developer/admin/components.md +711 -0
  25. package/dist/developer/admin/custom-css.md +243 -0
  26. package/dist/developer/admin/custom-javascript.md +116 -0
  27. package/dist/developer/admin/extending-ui.md +1964 -0
  28. package/dist/developer/admin/form-builder.md +444 -0
  29. package/dist/developer/admin/helper-methods.md +531 -0
  30. package/dist/developer/admin/navigation.md +805 -0
  31. package/dist/developer/admin/tables.md +491 -0
  32. package/dist/developer/advanced/adding_spree_to_rails_app.md +106 -0
  33. package/dist/developer/cli/quickstart.md +137 -0
  34. package/dist/developer/contributing/creating-an-extension.md +258 -0
  35. package/dist/developer/contributing/developing-spree.md +339 -0
  36. package/dist/developer/contributing/quickstart.md +32 -0
  37. package/dist/developer/contributing/updating-extensions.md +67 -0
  38. package/dist/developer/core-concepts/addresses.md +265 -0
  39. package/dist/developer/core-concepts/adjustments.md +107 -0
  40. package/dist/developer/core-concepts/architecture.md +177 -0
  41. package/dist/developer/core-concepts/calculators.md +323 -0
  42. package/dist/developer/core-concepts/customers.md +230 -0
  43. package/dist/developer/core-concepts/events.md +624 -0
  44. package/dist/developer/core-concepts/imports-exports.md +698 -0
  45. package/dist/developer/core-concepts/inventory.md +191 -0
  46. package/dist/developer/core-concepts/markets.md +250 -0
  47. package/dist/developer/core-concepts/media.md +167 -0
  48. package/dist/developer/core-concepts/metafields.md +187 -0
  49. package/dist/developer/core-concepts/orders.md +328 -0
  50. package/dist/developer/core-concepts/payments.md +710 -0
  51. package/dist/developer/core-concepts/pricing.md +163 -0
  52. package/dist/developer/core-concepts/products.md +360 -0
  53. package/dist/developer/core-concepts/promotions.md +322 -0
  54. package/dist/developer/core-concepts/reports.md +206 -0
  55. package/dist/developer/core-concepts/search-filtering.md +237 -0
  56. package/dist/developer/core-concepts/shipments.md +212 -0
  57. package/dist/developer/core-concepts/slugs.md +111 -0
  58. package/dist/developer/core-concepts/staff-roles.md +123 -0
  59. package/dist/developer/core-concepts/store-credits-gift-cards.md +317 -0
  60. package/dist/developer/core-concepts/stores.md +117 -0
  61. package/dist/developer/core-concepts/taxes.md +135 -0
  62. package/dist/developer/core-concepts/translations.md +120 -0
  63. package/dist/developer/core-concepts/users.md +299 -0
  64. package/dist/developer/core-concepts/webhooks.md +378 -0
  65. package/dist/developer/create-spree-app/quickstart.md +158 -0
  66. package/dist/developer/customization/api.md +93 -0
  67. package/dist/developer/customization/authentication.md +88 -0
  68. package/dist/developer/customization/checkout.md +204 -0
  69. package/dist/developer/customization/configuration.md +55 -0
  70. package/dist/developer/customization/decorators.md +523 -0
  71. package/dist/developer/customization/dependencies.md +232 -0
  72. package/dist/developer/customization/emails.md +21 -0
  73. package/dist/developer/customization/extensions.md +92 -0
  74. package/dist/developer/customization/metadata.md +236 -0
  75. package/dist/developer/customization/model-preferences.md +130 -0
  76. package/dist/developer/customization/permissions.md +265 -0
  77. package/dist/developer/customization/quickstart.md +229 -0
  78. package/dist/developer/customization/routes.md +24 -0
  79. package/dist/developer/customization/v4/admin-panel.md +78 -0
  80. package/dist/developer/customization/v4/authentication.md +210 -0
  81. package/dist/developer/customization/v4/checkout.md +212 -0
  82. package/dist/developer/customization/v4/deface.md +251 -0
  83. package/dist/developer/customization/v4/images.md +86 -0
  84. package/dist/developer/customization/v4/storefront.md +450 -0
  85. package/dist/developer/deployment/assets.md +87 -0
  86. package/dist/developer/deployment/aws.md +335 -0
  87. package/dist/developer/deployment/caching.md +27 -0
  88. package/dist/developer/deployment/cdn.md +39 -0
  89. package/dist/developer/deployment/database.md +155 -0
  90. package/dist/developer/deployment/docker.md +128 -0
  91. package/dist/developer/deployment/emails.md +77 -0
  92. package/dist/developer/deployment/environment_variables.md +111 -0
  93. package/dist/developer/deployment/heroku.md +51 -0
  94. package/dist/developer/deployment/render.md +95 -0
  95. package/dist/developer/getting-started/quickstart.md +82 -0
  96. package/dist/developer/how-to/custom-payment-method.md +374 -0
  97. package/dist/developer/how-to/custom-promotion.md +373 -0
  98. package/dist/developer/how-to/custom-report.md +387 -0
  99. package/dist/developer/how-to/custom-search-provider.md +230 -0
  100. package/dist/developer/multi-store/quickstart.md +71 -0
  101. package/dist/developer/multi-store/setup.md +38 -0
  102. package/dist/developer/multi-tenant/configuration.md +41 -0
  103. package/dist/developer/multi-tenant/core-concepts.md +75 -0
  104. package/dist/developer/multi-tenant/installation.md +96 -0
  105. package/dist/developer/multi-tenant/quickstart.md +20 -0
  106. package/dist/developer/multi-vendor/installation.md +45 -0
  107. package/dist/developer/multi-vendor/quickstart.md +17 -0
  108. package/dist/developer/sdk/admin/quickstart.md +22 -0
  109. package/dist/developer/sdk/authentication.md +89 -0
  110. package/dist/developer/sdk/configuration.md +225 -0
  111. package/dist/developer/sdk/quickstart.md +82 -0
  112. package/dist/developer/sdk/store/account.md +67 -0
  113. package/dist/developer/sdk/store/cart-checkout.md +140 -0
  114. package/dist/developer/sdk/store/markets.md +151 -0
  115. package/dist/developer/sdk/store/payments.md +96 -0
  116. package/dist/developer/sdk/store/products.md +149 -0
  117. package/dist/developer/sdk/store/wishlists.md +52 -0
  118. package/dist/developer/security/pci_compliance.md +15 -0
  119. package/dist/developer/security/security_policy.md +68 -0
  120. package/dist/developer/storefront/blocks.md +285 -0
  121. package/dist/developer/storefront/custom-css.md +260 -0
  122. package/dist/developer/storefront/custom-javascript.md +166 -0
  123. package/dist/developer/storefront/helper-methods.md +1288 -0
  124. package/dist/developer/storefront/links.md +298 -0
  125. package/dist/developer/storefront/nextjs/architecture.md +150 -0
  126. package/dist/developer/storefront/nextjs/customization.md +141 -0
  127. package/dist/developer/storefront/nextjs/deployment.md +180 -0
  128. package/dist/developer/storefront/nextjs/quickstart.md +92 -0
  129. package/dist/developer/storefront/nextjs/spree-next-package.md +314 -0
  130. package/dist/developer/storefront/pages.md +163 -0
  131. package/dist/developer/storefront/sections.md +569 -0
  132. package/dist/developer/storefront/storefront.md +56 -0
  133. package/dist/developer/storefront/themes.md +161 -0
  134. package/dist/developer/tutorial/admin.md +134 -0
  135. package/dist/developer/tutorial/extending-models.md +380 -0
  136. package/dist/developer/tutorial/file-uploads.md +121 -0
  137. package/dist/developer/tutorial/introduction.md +33 -0
  138. package/dist/developer/tutorial/model.md +41 -0
  139. package/dist/developer/tutorial/page-builder.md +487 -0
  140. package/dist/developer/tutorial/rich-text.md +73 -0
  141. package/dist/developer/tutorial/seo.md +332 -0
  142. package/dist/developer/tutorial/storefront.md +352 -0
  143. package/dist/developer/tutorial/testing.md +558 -0
  144. package/dist/developer/upgrades/2.0-to-2.1.md +46 -0
  145. package/dist/developer/upgrades/2.1-to-2.2.md +59 -0
  146. package/dist/developer/upgrades/2.2-to-2.3.md +44 -0
  147. package/dist/developer/upgrades/2.3-to-2.4.md +42 -0
  148. package/dist/developer/upgrades/3.0-to-3.1.md +47 -0
  149. package/dist/developer/upgrades/3.1-to-3.2.md +34 -0
  150. package/dist/developer/upgrades/3.2-to-3.3.md +70 -0
  151. package/dist/developer/upgrades/3.3-to-3.4.md +36 -0
  152. package/dist/developer/upgrades/3.4-to-3.5.md +44 -0
  153. package/dist/developer/upgrades/3.5-to-3.6.md +40 -0
  154. package/dist/developer/upgrades/3.6-to-3.7.md +62 -0
  155. package/dist/developer/upgrades/3.7-to-4.0.md +152 -0
  156. package/dist/developer/upgrades/4.0-to-4.1.md +92 -0
  157. package/dist/developer/upgrades/4.1-to-4.2.md +109 -0
  158. package/dist/developer/upgrades/4.10-to-5.0.md +129 -0
  159. package/dist/developer/upgrades/4.2-to-4.3.md +100 -0
  160. package/dist/developer/upgrades/4.3-to-4.4.md +125 -0
  161. package/dist/developer/upgrades/4.4-to-4.5.md +94 -0
  162. package/dist/developer/upgrades/4.5-to-4.6.md +119 -0
  163. package/dist/developer/upgrades/4.6-to-4.7.md +39 -0
  164. package/dist/developer/upgrades/4.8-to-4.9.md +24 -0
  165. package/dist/developer/upgrades/4.9-to-4.10.md +24 -0
  166. package/dist/developer/upgrades/4.x-to-4.8.md +52 -0
  167. package/dist/developer/upgrades/5.0-to-5.1.md +28 -0
  168. package/dist/developer/upgrades/5.1-to-5.2.md +127 -0
  169. package/dist/developer/upgrades/5.2-to-5.3.md +338 -0
  170. package/dist/developer/upgrades/5.3-to-5.4.md +248 -0
  171. package/dist/developer/upgrades/quickstart.md +36 -0
  172. package/dist/integrations/analytics/google-analytics.md +64 -0
  173. package/dist/integrations/analytics/google-tag-manager.md +78 -0
  174. package/dist/integrations/integrations.md +39 -0
  175. package/dist/integrations/marketing/klaviyo.md +99 -0
  176. package/dist/integrations/payments/adyen.md +90 -0
  177. package/dist/integrations/payments/paypal.md +41 -0
  178. package/dist/integrations/payments/razorpay.md +45 -0
  179. package/dist/integrations/payments/stripe.md +109 -0
  180. package/dist/integrations/search/meilisearch.md +236 -0
  181. package/dist/integrations/sso-mfa-social-login/admin-dashboard.md +57 -0
  182. package/dist/integrations/sso-mfa-social-login/storefront.md +56 -0
  183. package/package.json +27 -0
@@ -0,0 +1,444 @@
1
+ ---
2
+ title: Admin Form Builder API
3
+ sidebarTitle: Form Builder
4
+ ---
5
+
6
+ Spree provides a custom `Spree::Admin::FormBuilder` that extends Rails' standard FormBuilder with additional helper methods designed specifically for the admin interface. This form builder ensures consistent styling, error handling, and behavior across all admin forms.
7
+
8
+ ## Using the FormBuilder
9
+
10
+ The FormBuilder is automatically available in admin forms when using `form_with`:
11
+
12
+ ```erb
13
+ <%= form_with model: [:admin, @product] do |f| %>
14
+ <%= f.spree_text_field :name %>
15
+ <%= f.spree_text_area :description %>
16
+ <% end %>
17
+ ```
18
+
19
+ ## Common Options
20
+
21
+ All FormBuilder methods support these common options:
22
+
23
+ | Option | Type | Description |
24
+ |--------|------|-------------|
25
+ | `:label` | String or `false` | Custom label text, or `false` to hide the label entirely |
26
+ | `:required` | Boolean | Adds a red asterisk (*) indicator next to the label |
27
+ | `:help` | String | Help text displayed below the field |
28
+ | `:help_bubble` | String | Tooltip text displayed in a help bubble icon next to the label |
29
+ | `:class` | String | Additional CSS classes for the input element |
30
+
31
+ ## Text Input Methods
32
+
33
+ ### spree_text_field
34
+
35
+ Creates a text input field with Spree styling.
36
+
37
+ ```erb
38
+ <%= f.spree_text_field :name %>
39
+ <%= f.spree_text_field :sku, required: true %>
40
+ <%= f.spree_text_field :code, help: "Leave blank to auto-generate" %>
41
+ <%= f.spree_text_field :slug, help_bubble: "URL-friendly identifier" %>
42
+ ```
43
+
44
+ **Options:**
45
+ - All standard Rails `text_field` options
46
+ - All common FormBuilder options
47
+
48
+ ### spree_number_field
49
+
50
+ Creates a number input field with Spree styling.
51
+
52
+ ```erb
53
+ <%= f.spree_number_field :price, required: true, step: 0.01 %>
54
+ <%= f.spree_number_field :quantity, min: 0 %>
55
+ ```
56
+
57
+ **Options:**
58
+ - All standard Rails `number_field` options (`:min`, `:max`, `:step`)
59
+ - All common FormBuilder options
60
+
61
+ ### spree_money_field
62
+
63
+ Creates a locale-aware money/currency input field with automatic formatting. This field displays amounts in the currency's locale format (e.g., `1.234,56` for EUR, `1,234.56` for USD) and normalizes values to standard decimal format before form submission.
64
+
65
+ ```erb
66
+ <%= f.spree_money_field :amount, currency: 'USD' %>
67
+ <%= f.spree_money_field :price, currency: 'EUR', required: true %>
68
+ <%= f.spree_money_field :compare_at_amount, currency: @product.currency, label: false %>
69
+ ```
70
+
71
+ **Options:**
72
+
73
+ | Option | Type | Description |
74
+ |--------|------|-------------|
75
+ | `:currency` | String | Currency code (e.g., `'USD'`, `'EUR'`, `'PLN'`). Used to determine decimal/thousands separators and display the currency symbol |
76
+ | `:value` | BigDecimal, Float, String | Override the displayed value (will be formatted for the currency's locale) |
77
+ | `:prepend` | String | Text to prepend before the input field |
78
+ | `:append` | String | Text to append after the input field (defaults to currency symbol when `:currency` is provided) |
79
+ | `:disabled` | Boolean | Disable the input field |
80
+
81
+ All common FormBuilder options (`:label`, `:required`, `:help`, `:help_bubble`) are also supported.
82
+
83
+ **Features:**
84
+ - **Locale-aware display:** Values are displayed using the currency's decimal mark (e.g., comma for EUR/PLN, dot for USD)
85
+ - **Automatic normalization:** Values are converted to standard decimal format (with `.` as decimal separator) before form submission
86
+ - **Currency symbol:** Automatically appends the currency symbol when `:currency` option is provided
87
+ - **Mobile-friendly:** Uses `inputmode="decimal"` for appropriate mobile keyboard
88
+ - **Auto-formatting:** Values are reformatted on blur to ensure consistent display
89
+
90
+ **Example with nested form:**
91
+
92
+ ```erb
93
+ <%= f.fields_for :prices do |price_form| %>
94
+ <%= price_form.spree_money_field :amount,
95
+ currency: price_form.object.currency,
96
+ disabled: !can?(:manage, price_form.object),
97
+ label: false %>
98
+ <% end %>
99
+ ```
100
+
101
+ > **NOTE:** The money field uses a Stimulus controller (`money-field`) that handles formatting and normalization automatically. The decimal and thousands separators are determined by the currency's ISO standard configuration.
102
+
103
+ ### spree_email_field
104
+
105
+ Creates an email input field with Spree styling and HTML5 validation.
106
+
107
+ ```erb
108
+ <%= f.spree_email_field :email, required: true %>
109
+ <%= f.spree_email_field :contact_email,
110
+ help: "For customer support inquiries" %>
111
+ ```
112
+
113
+ **Options:**
114
+ - All standard Rails `email_field` options
115
+ - All common FormBuilder options
116
+
117
+ ## Date and Time Methods
118
+
119
+ ### spree_date_field
120
+
121
+ Creates a date picker input field.
122
+
123
+ ```erb
124
+ <%= f.spree_date_field :available_on %>
125
+ <%= f.spree_date_field :discontinue_on,
126
+ help: "Date when product will be discontinued" %>
127
+ ```
128
+
129
+ **Options:**
130
+ - All standard Rails `date_field` options (`:min`, `:max`)
131
+ - All common FormBuilder options
132
+
133
+ ### spree_datetime_field
134
+
135
+ Creates a datetime picker input field.
136
+
137
+ ```erb
138
+ <%= f.spree_datetime_field :published_at %>
139
+ <%= f.spree_datetime_field :sale_starts_at, required: true %>
140
+ ```
141
+
142
+ **Options:**
143
+ - All standard Rails `datetime_field` options
144
+ - All common FormBuilder options
145
+
146
+ ## Text Area Methods
147
+
148
+ ### spree_text_area
149
+
150
+ Creates a textarea with auto-grow functionality (expands as you type).
151
+
152
+ ```erb
153
+ <%= f.spree_text_area :description %>
154
+ <%= f.spree_text_area :notes, rows: 10 %>
155
+ <%= f.spree_text_area :meta_description,
156
+ help: "Used for SEO, maximum 160 characters" %>
157
+ ```
158
+
159
+ **Options:**
160
+ - `:rows` - Number of visible rows (default: 5)
161
+ - `:data` - Data attributes (default includes auto-grow Stimulus controller)
162
+ - All standard Rails `text_area` options
163
+ - All common FormBuilder options
164
+
165
+ **Auto-grow behavior:**
166
+ By default, the textarea automatically grows as the user types. This uses the `textarea-autogrow` Stimulus controller.
167
+
168
+ ### spree_rich_text_area
169
+
170
+ Creates a rich text editor using Trix.
171
+
172
+ ```erb
173
+ <%= f.spree_rich_text_area :description %>
174
+ <%= f.spree_rich_text_area :content, label: "Page Content" %>
175
+ ```
176
+
177
+ **Features:**
178
+ - WYSIWYG editing
179
+ - Basic formatting (bold, italic, lists, links)
180
+ - File attachments via Active Storage
181
+ - All common FormBuilder options
182
+
183
+ ## Select Methods
184
+
185
+ ### spree_select
186
+
187
+ Creates a select dropdown field.
188
+
189
+ ```erb
190
+ <%= f.spree_select :status,
191
+ ['draft', 'active', 'archived'],
192
+ {},
193
+ {} %>
194
+
195
+ <%= f.spree_select :tax_category_id,
196
+ Spree::Category.pluck(:name, :id),
197
+ { include_blank: 'Select Tax Category' } %>
198
+ ```
199
+
200
+ **With autocomplete:**
201
+
202
+ ```erb
203
+ <%= f.spree_select :country_id,
204
+ Spree::Country.pluck(:name, :id),
205
+ { autocomplete: true } %>
206
+ ```
207
+
208
+ **Parameters:**
209
+ 1. `method` - The attribute name
210
+ 2. `choices` - Array of options
211
+ 3. `options` - Select options (`:include_blank`, `:prompt`, `:autocomplete`)
212
+ 4. `html_options` - HTML attributes (`:class`, `:data`, `:disabled`)
213
+
214
+ **Options:**
215
+ - `:autocomplete` - Enables searchable dropdown with autocomplete functionality
216
+ - All standard Rails `select` options
217
+ - All common FormBuilder options
218
+
219
+ ### spree_collection_select
220
+
221
+ Creates a select dropdown from a collection of objects.
222
+
223
+ ```erb
224
+ <%= f.spree_collection_select :shipping_category_id,
225
+ ShippingCategory.all,
226
+ :id,
227
+ :name,
228
+ { include_blank: true },
229
+ {} %>
230
+
231
+ <%= f.spree_collection_select :tax_category_id,
232
+ TaxCategory.all,
233
+ :id,
234
+ :name,
235
+ { autocomplete: true, required: true },
236
+ {} %>
237
+ ```
238
+
239
+ **Parameters:**
240
+ 1. `method` - The attribute name
241
+ 2. `collection` - ActiveRecord collection or array of objects
242
+ 3. `value_method` - Method to call for option value (e.g., `:id`)
243
+ 4. `text_method` - Method to call for option text (e.g., `:name`)
244
+ 5. `options` - Select options (`:include_blank`, `:autocomplete`)
245
+ 6. `html_options` - HTML attributes
246
+
247
+ **Options:**
248
+ - `:autocomplete` - Enables searchable dropdown
249
+ - All standard Rails `collection_select` options
250
+ - All common FormBuilder options
251
+
252
+ ## Checkbox and Radio Methods
253
+
254
+ ### spree_check_box
255
+
256
+ Creates a styled checkbox with custom controls.
257
+
258
+ ```erb
259
+ <%= f.spree_check_box :active %>
260
+ <%= f.spree_check_box :featured, label: "Feature on homepage" %>
261
+ <%= f.spree_check_box :accept_terms, required: true %>
262
+ ```
263
+
264
+ **Options:**
265
+ - All standard Rails `check_box` options
266
+ - All common FormBuilder options
267
+
268
+ **Styling:**
269
+ Uses custom control classes for consistent appearance across the admin interface.
270
+
271
+ ### spree_radio_button
272
+
273
+ Creates a styled radio button with custom controls.
274
+
275
+ ```erb
276
+ <%= f.spree_radio_button :status, 'draft', id: 'status_draft' %>
277
+ <%= f.spree_radio_button :status, 'published', id: 'status_published' %>
278
+ ```
279
+
280
+ **Parameters:**
281
+ 1. `method` - The attribute name
282
+ 2. `tag_value` - The value for this radio option
283
+ 3. `options` - Options hash (must include `:id`)
284
+
285
+ **Options:**
286
+ - `:id` - Required HTML ID for the radio button
287
+ - All standard Rails `radio_button` options
288
+ - All common FormBuilder options
289
+
290
+ > **WARNING:** Radio buttons require unique IDs. Always specify the `:id` option.
291
+
292
+ ## File Upload Methods
293
+
294
+ ### spree_file_field
295
+
296
+ Creates a file upload field with image preview, drag-and-drop support, and optional cropping functionality.
297
+
298
+ ```erb
299
+ <%= f.spree_file_field :image %>
300
+ <%= f.spree_file_field :logo, width: 240, height: 240 %>
301
+ <%= f.spree_file_field :avatar, crop: true %>
302
+ <%= f.spree_file_field :featured_image, width: 1200, height: 600, crop: true %>
303
+ ```
304
+
305
+ **Options:**
306
+
307
+ | Option | Type | Default | Description |
308
+ |--------|------|---------|-------------|
309
+ | `:width` | Integer | 300 | Width of the image preview in pixels |
310
+ | `:height` | Integer | 300 | Height of the image preview in pixels |
311
+ | `:crop` | Boolean | `false` | Enable image cropping with recommended size indicator |
312
+ | `:auto_submit` | Boolean | `false` | Automatically submit form when file is selected |
313
+ | `:can_delete` | Boolean | `true` | Show delete button for removing uploaded image |
314
+ | `:css` | String | `''` | Additional CSS classes for the upload placeholder area |
315
+ | `:allowed_file_types` | Array | Image types | Specify the allowed file types |
316
+
317
+ All common FormBuilder options (`:label`, `:required`, `:help`, `:help_bubble`) are also supported.
318
+
319
+ **Features:**
320
+ - Drag-and-drop file upload
321
+ - Image preview after upload
322
+ - Optional image cropping with size recommendations
323
+ - Delete button to remove uploaded files
324
+ - Uses Active Storage direct upload
325
+
326
+ **Example with all options:**
327
+
328
+ ```erb
329
+ <%= f.spree_file_field :hero_video_background,
330
+ width: 1200,
331
+ height: 630,
332
+ crop: false,
333
+ auto_submit: false,
334
+ can_delete: true,
335
+ help_bubble: "This video will loop in the background",
336
+ label: 'Hero video background',
337
+ allowed_file_types: %w[video/mp4 video/webm video/ogg] %>
338
+ ```
339
+
340
+ ## Complete Form Example
341
+
342
+ Here's a complete example showing various FormBuilder methods:
343
+
344
+ ```erb
345
+ <div class="card mb-6">
346
+ <div class="card-header">
347
+ <h5 class="card-title">
348
+ <%= Spree.t(:general_settings) %>
349
+ </h5>
350
+ </div>
351
+
352
+ <div class="card-body">
353
+ <%= f.spree_text_field :name,
354
+ required: true,
355
+ help: "Product name as displayed to customers" %>
356
+
357
+ <%= f.spree_text_field :sku,
358
+ label: "SKU",
359
+ help_bubble: "Stock Keeping Unit - unique product identifier" %>
360
+
361
+ <%= f.spree_number_field :price,
362
+ required: true,
363
+ step: 0.01,
364
+ min: 0 %>
365
+
366
+ <%= f.spree_rich_text_area :description,
367
+ help: "Detailed product description with rich formatting" %>
368
+
369
+ <%= f.spree_collection_select :tax_category_id,
370
+ Spree::TaxCategory.all,
371
+ :id,
372
+ :name,
373
+ { include_blank: 'None', required: true },
374
+ {} %>
375
+
376
+ <%= f.spree_date_field :available_on,
377
+ label: "Available Date",
378
+ help: "Date when product becomes available for purchase" %>
379
+
380
+ <%= f.spree_check_box :active,
381
+ label: "Active" %>
382
+ </div>
383
+ </div>
384
+ ```
385
+
386
+ ## Error Handling
387
+
388
+ All FormBuilder methods automatically display validation errors below the field when present:
389
+
390
+ ```erb
391
+ <%= f.spree_text_field :name %>
392
+ ```
393
+
394
+ If `@product.errors[:name]` contains errors, they will be displayed automatically in red text below the input field.
395
+
396
+ ## Internationalization
397
+
398
+ Labels are automatically translated using Rails I18n. The FormBuilder looks for translations in this order:
399
+
400
+ 1. Custom label passed via `:label` option
401
+ 2. `spree.{attribute_name}` key
402
+ 3. `activerecord.attributes.spree/{model_name}.{attribute_name}` key
403
+
404
+ Example translations:
405
+
406
+ ```yaml
407
+ # config/locales/en.yml
408
+ en:
409
+ spree:
410
+ name: "Product Name"
411
+ sku: "SKU Code"
412
+ activerecord:
413
+ attributes:
414
+ spree/product:
415
+ available_on: "Available On Date"
416
+ discontinue_on: "Discontinuation Date"
417
+ ```
418
+
419
+ ## Styling and CSS Classes
420
+
421
+ All FormBuilder methods use consistent styling:
422
+
423
+ - **Form groups:** Each field is wrapped in a `.form-group` div
424
+ - **Input classes:** Text inputs use `.form-control` class
425
+ - **Select classes:** Dropdowns use `.custom-select` class
426
+ - **Checkboxes/Radios:** Use `.custom-control`, `.custom-checkbox`, `.custom-radio` classes
427
+
428
+ You can add additional classes via the `:class` option:
429
+
430
+ ```erb
431
+ <%= f.spree_text_field :name, class: 'form-control-lg' %>
432
+ ```
433
+
434
+ ## Best Practices
435
+
436
+ **Use the Spree FormBuilder methods** instead of standard Rails helpers for consistent styling
437
+
438
+ **Add `:required` option** to required fields for visual indication
439
+
440
+ **Use `:help` text** to provide guidance for complex fields
441
+
442
+ **Use `:help_bubble`** for additional context without cluttering the form
443
+
444
+ **Enable autocomplete** on selects with many options (> 20 items)