i have project have several content types (article, interview, etc) nested images. handle images, did implement popup 'image upload' box (using combination of paperclip , uploadify) user can upload image article.
the process works this: user clicks 'upload image' icon, box pops can add paperclip file upload fields upload many images want. uploadify instantly uploads photos , assigns them article id number they're attached to. photo's html gets sent wysiwyg editor. if want delete photos well, can. if sounds wordpress, that's it's based on.
anyway, have working great. photos remain associated , attached respective articles, opposed throwing in 1 huge folder (like many wysiwyg image uploaders do) can add/delete anything.
but there 1 little flaw this...as said, image assigned content's id number when upload performed. well, can see how issue when creating brand new article, new article doesn't have id number before saving it. image upload fails. thus, whole process works on 'edit/update' action.
in interim, told team make sure save article first, when go edit can upload images body. naturally, forget it's easy thing do, , user-unfriendly, gotta solve this.
i see 2 ways can go this.
assign id (hidden field or otherwise) article on 'new' form. appease uploader fills 'nil' value errors out on, when article gets saved first time, assign same number. see potential issue...what if user creates article @ same time , database assigns identical id number?
i noticed moment create new wordpress document, new document 'autosaves' draft. line of thinking this...when user goes create new document, 'new' action trigger 'save' operation, bypass validation errors (since fields blank), redirect 'edit' action. way, id saved , work normal, , entire process may seamless user.
how handle situation? suggested above, or there better way?
i decided go second route , perform save on new action , bypassing validations, redirecting edit form, throwing "autosaved" flash message in measure. works well.
Comments
Post a Comment