public function onRelationManageDelete()
    {
        $this->beforeAjax();

        /*
         * Multiple (has many, belongs to many)
         */
        if ($this->viewMode == 'multi') {
            if (($checkedIds = post('checked')) && is_array($checkedIds)) {
                 foreach ($checkedIds as $relationId) {
                    if (!$obj = $this->relationModel->find($relationId)) {
                        continue;
                    }

                    $obj->delete();
                }
            }
        }
        /*
         * Single (belongs to, has one)
         */
        elseif ($this->viewMode == 'single') {
            $relatedModel = $this->viewModel;
            if ($relatedModel->exists) {
                $relatedModel->delete();
            }

            $this->viewWidget->setFormValues([]);
            $this->viewModel = $this->relationModel;
        }

        return $this->relationRefresh();
    }
public function onRelationManageDelete()
    {
        $this->beforeAjax();

        /*
         * Multiple (has many, belongs to many)
         */
        if ($this->viewMode == 'multi') {
            if (($checkedIds = post('checked')) && is_array($checkedIds)) {
                 foreach ($checkedIds as $relationId) {
                    if (!$obj = $this->relationModel->find($relationId)) {
                        continue;
                    }

                    $obj->delete();
                }
            }
        }
        /*
         * Single (belongs to, has one)
         */
        elseif ($this->viewMode == 'single') {
            $relatedModel = $this->viewModel;
            if ($relatedModel->exists) {
                $relatedModel->delete();
            }

            $this->viewWidget->setFormValues([]);
            $this->viewModel = $this->relationModel;
        }

        return $this->relationRefresh();
    }
public function onRelationManageDelete ( ) { $ this -> beforeAjax ( ) ; /*
         * Multiple (has many, belongs to many)
         */ if ( $ this -> viewMode == 'multi' ) { if ( ( $ checkedIds = post ( 'checked' ) ) && is_array ( $ checkedIds ) ) { foreach ( $ checkedIds as $ relationId ) { if ( ! $ obj = $ this -> relationModel -> find ( $ relationId ) ) { continue ; } $ obj -> delete ( ) ; } } } /*
         * Single (belongs to, has one)
         */ elseif ( $ this -> viewMode == 'single' ) { $ relatedModel = $ this -> viewModel ; if ( $ relatedModel -> exists ) { $ relatedModel -> delete ( ) ; } $ this -> viewWidget -> setFormValues ( [ ] ) ; $ this -> viewModel = $ this -> relationModel ; } return $ this -> relationRefresh ( ) ; }
Delete an existing related model completely
Delete an existing related model completely