Skip to content

[6.x] Add min, max, and step attributes to Integer and Float fieldtypes - #12395

Merged
jasonvarga merged 13 commits into
statamic:masterfrom
ELowry:feature/integer-field-attributes
Nov 6, 2025
Merged

[6.x] Add min, max, and step attributes to Integer and Float fieldtypes#12395
jasonvarga merged 13 commits into
statamic:masterfrom
ELowry:feature/integer-field-attributes

Conversation

@ELowry

@ELowry ELowry commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Addresses statamic/ideas#1368 and statamic/ideas#1092

This PR introduces support for the native HTML min, max, and step attributes to the Integer fieldtype:

  • Adds min, max, and step options to the blueprint builder UI.
  • Renders the attributes in the field's HTML view.
  • Renders the attributes in the field's Vue rendering.

Important note

I've done my best to follow the existing patterns in the codebase, but as I'm not deeply familiar with all of Statamic's architecture and do not currently have time to test my changes in a sandbox.
However, since the changes seem pretty straightforward, I thought it best to still create a PR with this message included; please excuse me for the break in protocol.

Thanks!

- Adds min, max, and step options to the blueprint builder UI.
- Renders the attributes in the field's HTML view.
- Renders the attributes in the field's Vue rendering.
@ELowry ELowry changed the title feat: Add min, max, and step attributes to Integer fieldtype [4.x] Add min, max, and step attributes to Integer fieldtype Sep 10, 2025
@ELowry ELowry changed the title [4.x] Add min, max, and step attributes to Integer fieldtype [5.x] Add min, max, and step attributes to Integer fieldtype Sep 10, 2025
class_attributes_separation
indentation_type
class_attributes_separation
@ELowry
ELowry marked this pull request as ready for review September 10, 2025 20:27
@ELowry

ELowry commented Oct 4, 2025

Copy link
Copy Markdown
Contributor Author

I have now fully tested this in a local deployment, and can confirm that it functions as intended.

Further testing is still worth it IMHO, as I was not familiar with this local deployment method and may not have done it fully properly.

Use in a blueprint configuration:

image

The blueprint in use

image

The generated html

<input id="field_quantity" name="quantity" type="number" step="5" min="10" max="100" class="input-text">

How it acts

The browser correctly uses the min, max, and step values, gating and "stepping" the input.

The result in a simple view

image

Note: I changed the value between these two screenshots, ignore the difference.

@jasonvarga jasonvarga changed the title [5.x] Add min, max, and step attributes to Integer fieldtype [5.x] Add min, max, and step attributes to Integer and Float fieldtypes Nov 6, 2025
@jasonvarga

jasonvarga commented Nov 6, 2025

Copy link
Copy Markdown
Member

There were some extra moving parts needed for this.

There's actually a breaking change too unfortunately, so this will need to target v6.
By adding the min/max/step fields to the fieldtype configs, their values would forcefully be 0. So if you dont set a min/max/step, your field would get stuck on zero and you wouldn't be able to change it.
The breaking change is that I had to allow null values.

I also removed the "multiples of step" validation rule. A user might use the step value as just a UI helper. They might still be fine with values manually typed in between the steps. The user could manually add the multiple validation rule.

# Conflicts:
#	resources/js/components/fieldtypes/FloatFieldtype.vue
#	resources/js/components/inputs/Text.vue
#	src/Fieldtypes/Integer.php
@jasonvarga jasonvarga changed the title [5.x] Add min, max, and step attributes to Integer and Float fieldtypes [6.x] Add min, max, and step attributes to Integer and Float fieldtypes Nov 6, 2025
@jasonvarga
jasonvarga changed the base branch from 5.x to master November 6, 2025 17:50
@jasonvarga
jasonvarga merged commit 8e506a4 into statamic:master Nov 6, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants