fix: show create user errors inside dialog, pre-fill form on error
Used novalidate + server-side validation so errors appear in the dialog rather than as browser-native popups. Form fields retain submitted values. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -134,7 +134,6 @@ async def admin_create_user(request: Request, db: Session = Depends(get_db)):
|
||||
errors.append("Пользователь с таким email уже существует")
|
||||
|
||||
if errors:
|
||||
# Re-render list page with errors and dialog open
|
||||
q = db.query(User)
|
||||
total = q.count()
|
||||
users = q.order_by(User.created_at.desc()).limit(PAGE_SIZE).all()
|
||||
@@ -148,6 +147,13 @@ async def admin_create_user(request: Request, db: Session = Depends(get_db)):
|
||||
"total_pages": max(1, (total + PAGE_SIZE - 1) // PAGE_SIZE),
|
||||
"total": total,
|
||||
"create_errors": errors,
|
||||
"create_form": {
|
||||
"first_name": first_name,
|
||||
"last_name": last_name,
|
||||
"email": email,
|
||||
"phone": phone or "",
|
||||
"role": role_str,
|
||||
},
|
||||
})
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user