Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:26:33+00:00 2026-05-27T20:26:33+00:00

I have two models ‘Company’ and ‘Vehicle’ And two tables in database named same

  • 0

I have two models ‘Company’ and ‘Vehicle’

And two tables in database named same as ‘company_master’ and ‘vehicle_master’

company_master
fields: id, 
        name, 
        vehicle type, 
        country

vehicle_master
fields: id (auto increment), 
        company_id (foreign key),
        model_name,
        website,
        comments

When I select a random company, from CGridView to update record, I will get a form to update, that’s all fine.

But I need a blank form for vehicle_master to create a record, inside company’s update form.

Form Example

Above form is example of my html page “update” of company, along with initially “blank” form of Vehicle Detail.

I want to insert a new record when I click Add button of Vehicle Detail form.

Thanks in advance. God Bless Merry Christmas 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:26:34+00:00Added an answer on May 27, 2026 at 8:26 pm

    If i understood your question correctly then this is a multi-model-form task, there are plenty of good examples for that, including this one http://www.yiiframework.com/wiki/19/how-to-use-a-single-form-to-collect-data-for-two-or-more-models/ and this one here: multi model forms in yii

    The only two slight differences in your case [from the second link code]are:

    1. You will need to put the controller code in the Update action for your Company controller instead of the create action according to your business logic.
    2. You will need to add additional button to add vehicle independently, by simply sending the new vehicle params to the create action of your Vehicle controller.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models Company and Role related by has_many and belongs_to association respectively.
I have two models: class Studio(models.Model): name = models.CharField(Studio, max_length=30, unique=True) class Film(models.Model): studio
I have two models like this: class Store(models.Model): name = models.CharField(max_length=255) class Order(models.Model): store
I have two Models, one that has the name Exam and one that has
I have two models: Company and User they have a has_and_belongs_to_many relationship. I'm using
I have two models - category and article. I have pretty much the same
I have two models for store and city: class City(models.Model): name = models.CharField() slug
I have two models in the same application. The application is called News, and
I have two models than inherited from the same abstract base class. I would
I have two models: Company and Person class Person < ActiveRecord::Base belongs_to :company end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.