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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:16:33+00:00 2026-06-02T04:16:33+00:00

I have a page with Groups of Teams which has delete team button next

  • 0

I have a page with Groups of Teams which has delete team button next to it.
When team is not in group it has checkbox and button to add team to group.
I wrote in actionView that will render a list of groups with teams.

actionView in GroupController

public function actionView($id) {
    $group = $this->loadModel($id);

    $teamlst = Group::getAllTeamOfGroup($id);
    $teamnotlst = Group::getAllTeamNotInGroup($id);

    // Submit
    $preSelectedItems = array();
    if (isset($_POST['teamlist'])) {
        $preSelectedItems = array();
        foreach ($_POST['teamlist'] as $selectedItem) {
            $preSelectedItems[] = $selectedItem;
        }
    }
   // $teamNo = CHtml::listData($teamnotlst, 'id', 'name');

    //Delete       




    $this->render('view', array(
        'model' => $group,
        'teamlst' => $teamlst,
        'preSelectedItems'=> $preSelectedItems,
        'group_id'=>$id,
        'teamnotlst' => $teamnotlst,
    ));

    if(isset($_POST['btndeleteteam'])){
            TeamGroup::model()->deleteTeamGroup($team->id, $model->ID);
    }

}

in view file

<div class="action">    
    <input type="submit" name="btnupdateteam" value="Update Team">        
</div>
<?php echo CHtml::endForm(); ?>
<div class ="team">

<div class="column1">
    <?php foreach ($teamlst as $team): ?>

        <div class="row">
            <?php
            echo $team->name;

            ?> 
            <input type="submit" name="btndeleteteam" value="Delete  Team">
            <?php
            if(isset($_POST['btndeleteteam'])){
                TeamGroup::model()->deleteTeamGroup($team->id, $model->ID);    

            }?>
        </div>


    </div><!-- comment -->
<?php endforeach; ?>
    <?php    

    $preSelectedItems = array();
        if (isset($_POST['teamlist'])) {
            $preSelectedItems = array();
            foreach ($_POST['teamlist'] as $selectedItem) {
                $preSelectedItems[] = $selectedItem;
            }
        }

    $teamNo = CHtml::listData($teamnotlst, 'id', 'name');
    echo CHtml:: checkBoxList('teamlist', $preSelectedItems, $teamNo);
    ?>

</div>

<div class ="team available">

</div>

My idea is that when you click delete team button it will delete team from group and I has a method for this

TeamGroup::model()->deleteTeamGroup($team->id, $model->ID);    

When team not in group it will has checkbox and update button that will add team to group if checkbox is checked.

Thank for advance!

  • 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-02T04:16:34+00:00Added an answer on June 2, 2026 at 4:16 am

    if i understand right what is your problem then you need to read this doc chapter

    http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#action

    all your actions i.e. delete or add must reside in controller and not in view

    instead of this in view:

            if(isset($_POST['btndeleteteam'])){
                TeamGroup::model()->deleteTeamGroup($team->id, $model->ID);    
    
            }?>
    

    you must add something like this into controller

    public function actionDelete($id) {
        TeamGroup::model()->deleteTeamGroup($id);    
        $this->redirect('group/view');
    }
    

    and instead of this

    <input type="submit" name="btndeleteteam" value="Delete  Team">
    

    something like this must be in a view

    <a href="<?php echo Yii::app()->createUrl("group/delete",array('id'=>$team->id));?>">delete</a>
    

    or you can modify CGridView to suite your needs

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

Sidebar

Related Questions

I have 2 different group page with 2 look alike classes which using the
I have Page Tab App, which has a landing page with a Log In
I have a page that has a around 30 links divided among 6 groups.
Friends, My apex page has several different radio groups, each one can have the
I have a page on which user can dynamically create some identical groups of
I have a group of radio buttons on my page like this: ALL (x)
On my web page, I'd like to have a group of several concentric circles
I have page scans of various sizes in JPG format which I convert to
I have page where user upload they file to my web server which get
I have page which is redirected from htaccess. now I can pass the German

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.