We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The pattern you are showing right now makes the browser remember the request as submit, and thereby refresh will submit again.
I created a flash system which (Will create a package just for that soon) (https://github.com/nodes-vapor/admin-panel/tree/master/Sources/AdminPanel/Support/Flash)
But I was doing the same pattern for this
Middleware to add fieldset to session from response storage https://github.com/nodes-vapor/admin-panel/blob/master/Sources/AdminPanel/Support/Middlewares/FieldsetMiddleware.swift
Extension to response for easier adding fieldset https://github.com/nodes-vapor/admin-panel/blob/master/Sources/AdminPanel/Support/Extensions/Response%2BFieldset.swift
Pull out fieldset from Form, either from session or the static let https://github.com/nodes-vapor/admin-panel/blob/master/Sources/AdminPanel/Support/Extensions/Form%2BSession.swift
This will make it possible to make 2 funcs, 1-view 2-submit
View
public func create(request: Request) throws -> ResponseRepresentable { return try drop.view.make("BackendUsers/edit", [ "fieldset": BackendUserForm.getFieldset(request) ], for: request) }
Submit
public func store(request: Request) throws -> ResponseRepresentable { do { // Validate let backendUserForm = try BackendUserForm(validating: request.data) // Store var backendUser = BackendUser(form: backendUserForm) try backendUser.save() return Response(redirect: "/admin/backend_users").flash(.success, "User created") }catch FormError.validationFailed(let fieldSet) { return Response(redirect: "/admin/backend_users/create").flash(.error, "Validation error").withFieldset(fieldSet) }catch { return Response(redirect: "/admin/backend_users/create").flash(.error, "Failed to create user") } }
If you feel this is something you want in the package, I can make a PR next week!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The pattern you are showing right now makes the browser remember the request as submit, and thereby refresh will submit again.
I created a flash system which (Will create a package just for that soon) (https://github.com/nodes-vapor/admin-panel/tree/master/Sources/AdminPanel/Support/Flash)
But I was doing the same pattern for this
Middleware to add fieldset to session from response storage
https://github.com/nodes-vapor/admin-panel/blob/master/Sources/AdminPanel/Support/Middlewares/FieldsetMiddleware.swift
Extension to response for easier adding fieldset
https://github.com/nodes-vapor/admin-panel/blob/master/Sources/AdminPanel/Support/Extensions/Response%2BFieldset.swift
Pull out fieldset from Form, either from session or the static let
https://github.com/nodes-vapor/admin-panel/blob/master/Sources/AdminPanel/Support/Extensions/Form%2BSession.swift
This will make it possible to make 2 funcs, 1-view 2-submit
View
Submit
If you feel this is something you want in the package, I can make a PR next week!
The text was updated successfully, but these errors were encountered: