Tabs - adding related models dynamically via AJAX

Hi folks,

The view I am currently working on is one which displays information about a single candidate in the database of a recruitment agency. I am using Bootstrap Tabs to separate out the information about the client into different tabs such as Overview, Contact, Files etc etc.

I am looking to dynamically add related information to the view i.e. I have a table for candidate emails and I would like to have a system where on the contact tab I have an ADD button for adding a new email, phone number etc. I would like to use AJAX to both add a new HTML form to the view as well as model validation.

I would like to hear if anyone has attempted this scenario before? Rather than using a traditional CRUD form, I am considering having a system where the controller run by the button click grabs a new ActiveRecord instance of the required model and use Kartik’s GridView with the EDIT option triggered as the view. I am still in the process of working out how to do this and I am not sure yet if this can be done. The other option I would have would be to use a modal to add the new model and when the model is successfully saving, close the modal and reload the current view.

As I said, as this is fairly complex and bespoke, I would interested in hearing if any other developers out there have attempted anything like this.

Thanks in advance.

U4EA

Where exactly do you see potential problems? What you describe sounds pretty much standard.

Well I am looking at a scenario where I will be dynamically adding widgets to the page and I need to look at how that can be done i.e. I want to be able to add new related models without having to leave the current views but then if I want to do this I need to look into specific inline scripts for selecting and editing specific models based on their CSS ID.

The other option is simply to add these models the more traditional way just now and see about developing a more integrate scenario later on.