Skip to content

Commit 4f4e065

Browse files
Update NumberInput props from validate functions. (#795)
1 parent ff7eedf commit 4f4e065

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

aiohttp_admin/backends/sqlalchemy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ def __init__(self, db: AsyncEngine, model_or_table: Union[sa.Table, type[Declara
206206
props = props.copy()
207207
show = c is not table.autoincrement_column
208208
props["validate"] = self._get_validators(table, c)
209+
if inp == "NumberInput":
210+
for v in props["validate"]:
211+
if v["name"] == "minValue":
212+
props["min"] = v["args"][0]
213+
elif v["name"] == "maxValue":
214+
props["max"] = v["args"][0]
209215
self.inputs[c.name] = comp(inp, props) # type: ignore[assignment]
210216
self.inputs[c.name]["show_create"] = show
211217
field_type: Any = c.type.python_type

0 commit comments

Comments
 (0)