⚠ 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

Adding child data dynamically



azielinsky

azielinsky
  • profile picture
  • Member

Posted 23 November 2013 - 23:02 PM

Hello there.I think i'm bringing a challenging question to the table.

 

Let's imagine that i have a model where i have Offices and Employees that work at each office and each one has the corresponding office_id

 

I'm trying to achieve a form where for example if i'm editing/creating an office and i want to put a button where i can add employees dynamically without exiting the Office form.

 

Here is an example of the functionality using grocery CRUD but i haven't manage to replicate it
http://www.getnocms.com/example/manage_city/index/edit/20

 

Does anyone have an idea of where should i start

 

Thanks in advance for your help

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 24 November 2013 - 05:25 AM

Hi azielinsky

 

Nice question. I will like to share this a scenario as how you can go about on the same. But this is possible only after the office is added. Cuz that will give ability to assign the newly created office id. Of course this will require a certain tweeks but surely should work out.

Here is what i can suggest..

If you doing it all from read ... great - no need to deal a lot of this ..

THE READ WAY - Where you can add 2 column and have a callback_column on both

1 - add for a button

2 - add space / iframe.

Also you have to add up a script that will execute the function to call up the employee grid into the iframe with pre-passed office id ... that can go as hidden value with the employees being added out there.

 

IF you planning to do the same with Add form -

What you need to do is = follow up almost the same things as for the READ state - but an additional stuff would be - u need to add callback after insert (of each employee) and store the ID of each employee added for the new office into the session.

And you need to add one callback after insert (for the office) and there you have to assign the generated office id to all the employees in the session.

 

I know looks a little complex but a doable solution for sure ....

 

Happy GCing :)


ari

ari
  • profile picture
  • Member

Posted 22 December 2013 - 04:37 AM

Any body can do that with standard grocerycrud data example and put into grocerycrud master example ?