⚠ 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

How to figure out what state is now?



Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 17 September 2014 - 15:46 PM

Hi guys! I have a simple question that should understand by everyone i think

How figure out what state is now when i uploading file? I.e. I need to know when i am upload file either in edit record or add new record

I think about solution with using session but maybe exist more easy way? Did anyone face with this situation? Thanks

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 18 September 2014 - 03:20 AM

Well my friend .. when u upload the file - the state is - upload_file

If u wish to know in which state the uploads happening - u can look out for the value of your primary key in the post. If the value is blank or 0 ....  or if the primary key misses in the post (usually it will miss out in state of add) - the state is add ... else if it exists with a value - it is edit.

 

Happy GCing :)


Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 18 September 2014 - 12:34 PM

Hi! Nice to see you again Amit! Thanks for reply. So I think about your solution too but it doesn't seem to work :(

That is what i am do - check if exist primary key like ->   !empty($crud->state_info->primary_key) , am i right?

So in edit state this condition false but when state is upload_file - this condition always true ( i.e. $crud->state_info->primary_key is NULL ) regardless state before - edit or add or anything else at all

 

Conclusion - in upload state i have primary key is NULL. Could you check out this? many thanks Amit, you are the best

(Solution for me, just save to session key and state before upload_state)

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 18 September 2014 - 13:14 PM

well actually it even surprised me.. :) ...

i was expecting the id to be passed in as hidden value ... but it aint there...

well.. if u want it @the state of js (post upload or something) - u might be able to take it back from the form action url...

else if required @server level.. add an extra field with value (blank @time of add and id @time of edit) that will be submitted

but this then will require u to be cleared out before insert / update..

i know this is a crude way - yr discovery is worth keeping it.. but this 1 .. will ensure u the absolute value :)

 

Happy GCing :)


Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 18 September 2014 - 13:29 PM

Yeah, one possible solution is parse segments with state and primary key if it exists. But i stay with session solution.

This all i need just to set upload folder name with primary key or record, and when i upload file then primary key just vanish and file upload in wrong place :(

Well, now we know why so and possibly solutions, and maybe it will be helpful to someone :) Once again, many thanks Amit!