⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Open fancybox after inserting



Helton Eduardo Ritter
  • profile picture
  • Member

Posted 24 January 2013 - 19:03 PM

Hello. First, this CRUD is awesome!

Second. I have a question :)

I'm creating a page where I have to insert in a table "products" and this product have multiple images. [b]This images paths are not stored in DB[/b], just according with the code of the product inserted, a new folder are created, and the pictures go inside.

The porblem is: I can't in the same page in the add action put a button and open a fancybox, and inside do the [b]multiupload [/b]because the new product are not saved yet, so I don't know the ID (pk) to create a folder.

If I take the max(ID) +1, and use it, the user can open the add page, upload photos and NOT SAVE the product. So, when the next user add another product, the photos will be already there. But from the wrong product.

My try was use a callback "callback_after_insert" and from inside tell to open a new Fancybox window to the user add photos from the product just saved. But any JS that I send to output aparently are not executed.

Someone have a idea so work around it?

Thanks in advance.

victor
  • profile picture
  • Member

Posted 24 January 2013 - 23:57 PM

Hi! Did you made the uploader independently or you use a third party library?

Helton Eduardo Ritter
  • profile picture
  • Member

Posted 25 January 2013 - 12:49 PM

It is another method in the same controller with grocery, and it opens another view. Separately.

I'm using uploadify (http://www.uploadify.com/demos/)

This button on the side of the text filed where user fill the name of the product, I've added via JS append, and they call to open fancybox.

victor
  • profile picture
  • Member

Posted 25 January 2013 - 14:01 PM

as solution I can try this:
step 1: disallow the 'add' method.
step 2: create an action via the add_action function.
step 3. create a new method in your controller for example 'add_new_row'.
step 4. via that method insert one empty row into table and get the last id. now you have this id.
step 5 : then create redirect to the edit page.
in other words you haven't add page. you have the edit page.
Sorry for my English.

victor
  • profile picture
  • Member

Posted 25 January 2013 - 14:10 PM

you can use cookies as solution too. after uploading files create an array of images. then use 'after insert' function and insert data from cookies into database.

Helton Eduardo Ritter
  • profile picture
  • Member

Posted 25 January 2013 - 16:48 PM

Humm... good logic! It may work. I will try. Thanks!