-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
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
Editable submissions #248
Comments
@fanglinnw , can you weigh in on this? We're looking for possible short-term solutions so users can save and come back to their submissions. John has more information on why the file uploads complicate this ticket, but this is assigned to Matt |
@mattbaumann1 @jseraf Membership allows applicant to save file uploads in an application that's not submitted. So I think this is possible in Competition too. |
Note: please don't use the above code I linked in Membership because it has a serious bug that's causing . me great pain right now. |
here's what I figured out so far. To preserve the previously uploaded file, you need to add a hidden field before the file_field, and turn on the direct_upload option on the field_field: <%= form.hidden_field :file, value: form.object.file.signed_id if form.object.file.attached? %>
<%= form.file_field :file, direct_upload: true %> It's important to place the hidden_field before the file_field to allow updating existing upload (the last param with the same key takes precedence and this behavior is ensured because that's how the check_box field works in Rails, see the "Gotcha" secion in https://apidock.com/rails/ActionView/Helpers/FormHelper/check_box). With this, you don't need to do any hack in the controller for the "create" action. for the "update" action, if the file is on a nested child record, there's a known issue (rails/rails#37701) of not attaching new file during updates on the parent object. you can add a work-around on the child model like this: class Parent
has_many :children
accepts_nested_attributes_for :children
...
end
class Child
belongs_to :parent
has_one_attached :file
...
def changed_for_autosave?
super || file.changed_for_autosave?
end
end |
In some initial testing the changed_for_autosave? method does not seem like it is necessary in Rails 5 but @fanglinnw says that it will be required in Rails 6. |
Per discussion on 2/3/2020 -- saving a draft would require all the validations on the form that would be required on submission. We can revisit relaxing that later. |
This includes adding the HTML checks back on the fields.
add draft state to submissions. #248
5 votes
The text was updated successfully, but these errors were encountered: