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 7903835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:50:47+00:00 2026-06-03T09:50:47+00:00

For the following database: TABLES: user: [id,username] project: [id,name] project_user_assignment: [user_id,project_id,role] When a new

  • 0

For the following database:

TABLES:
user: [id,username]
project: [id,name]
project_user_assignment: [user_id,project_id,role]

When a new project is being created I’d like to show a dropdown with the available users to manage the project and when saving it insert into project_user_assignment the row

[user_id,project_id,‘manager’]

I’m starter with yii and don’t know where (class,method) I must do the insert and how to return an error if in the moment of the insert the query fails

  • 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-06-03T09:50:48+00:00Added an answer on June 3, 2026 at 9:50 am

    To display a drop down list in the you can use the foliowing code:

    <?php echo CHtml::dropDownList(null, 
         'type',
         CHtml::listData(
            User::model()->findAll(),
            'id',
            'username',
         ),
         array('empty' => 'Select a manager from the list ... ', 'id'=>'manager_list')
      );?>
    

    to update the corresponding field of the project_user_assignment model use the following:

     <?php
          <div class="row">
                  <?php echo $form->labelEx($model,'user_id'); ?> // Here I assume you have the $model variable set to Project_user_assignemenet ... if not (which probably is the case since you are creating a new project, set a new $model2 variable in the controller and use $model2 instead of $model)
                  <?php echo $form->textArea($model,'user_id'); ?>
                  <?php echo $form->error($model,'user_id'); ?>
          </div>
     ?>
     <script>
         $('#manager_list').on('change', function(e) {
                 $('#Project_user_assignemenet_user_id').val($(this).val());  // Here id maybe wrong! Check them.
                 return true;
         });
    </script>
    

    and finally in the controller you just save the model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following database tables: Table1: User UserId Username Table2: Role RoleId Rolename
I have the following (simplified) database tables: Products - ProductID, int, PK - Name,
I have a User and an Admin role in my project. I created my
I have the following tables in the database. users ----------------- | id | username
I have the following tables in the database. users ----------------- | id | username
I have two tables with a Many-To-Many relationship like this: User( emailaddress , Name)
I have two tables like User and UserInfo UsersInfo UserId UserName Email Password LastLoginDate
Consider for instance my following database model. UserTable(Id, Username) TextContentTable(Id, Name, Description, CreatedByUserId, ModifiedByUserId,
I have two database tables with the following structure: actions: action_id int(11) primary key
I need help on the best way to design a database/tables for the following

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.