public function handleGroupAssignment($grid, $request) {
		$list = $grid->getList();
        
        // (copied from GridFieldOrderableRows::handleReorder)
		$modelClass = $grid->getModelClass();
		if ($list instanceof ManyManyList && !singleton($modelClass)->canView()) {
			$this->httpError(403);
		} else if(!($list instanceof ManyManyList) && !singleton($modelClass)->canEdit()) {
			$this->httpError(403);
		}
        //

		$item_id   = $request->postVar('groupable_item_id');
		$group_key   = $request->postVar('groupable_group_key');
        if($group_key=='none') $group_key = '';
		$item = $list->byID($item_id);
        $groupField = $this->getOption('groupField');

		// Update item with correct Group assigned (custom query required to write m_m_extraField)
//        DB::query(sprintf(
//            "UPDATE `%s` SET `%s` = '%s' WHERE `BlockID` = %d",
//            'SiteTree_Blocks',
//            'BlockArea',
//            $group_key,
//            $item_id
//        ));

        if ($list instanceof ManyManyList && array_key_exists($groupField, $list->getExtraFields())) {
            // update many_many_extrafields (MMList->add() with a new item adds a row, with existing item modifies a row)
            $list->add($item, array($groupField => $group_key));
        } else {
            // or simply update the field on the item itself
            $item->$groupField = $group_key;
            $item->write();
        }

        $this->extend('onAfterAssignGroupItems', $list);
        
        // Forward the request to GridFieldOrderableRows::handleReorder (if GridFieldOrderableRows)
        $orderableRowsComponent = $grid->getConfig()->getComponentByType('GridFieldOrderableRows');
        if($orderableRowsComponent) {
            return $orderableRowsComponent->handleReorder($grid, $request);
        } else {
            return $grid->FieldHolder();
        }

	}
public function handleGroupAssignment($grid, $request) {
		$list = $grid->getList();
        
        // (copied from GridFieldOrderableRows::handleReorder)
		$modelClass = $grid->getModelClass();
		if ($list instanceof ManyManyList && !singleton($modelClass)->canView()) {
			$this->httpError(403);
		} else if(!($list instanceof ManyManyList) && !singleton($modelClass)->canEdit()) {
			$this->httpError(403);
		}
        //

		$item_id   = $request->postVar('groupable_item_id');
		$group_key   = $request->postVar('groupable_group_key');
        if($group_key=='none') $group_key = '';
		$item = $list->byID($item_id);
        $groupField = $this->getOption('groupField');

		// Update item with correct Group assigned (custom query required to write m_m_extraField)
//        DB::query(sprintf(
//            "UPDATE `%s` SET `%s` = '%s' WHERE `BlockID` = %d",
//            'SiteTree_Blocks',
//            'BlockArea',
//            $group_key,
//            $item_id
//        ));

        if ($list instanceof ManyManyList && array_key_exists($groupField, $list->getExtraFields())) {
            // update many_many_extrafields (MMList->add() with a new item adds a row, with existing item modifies a row)
            $list->add($item, array($groupField => $group_key));
        } else {
            // or simply update the field on the item itself
            $item->$groupField = $group_key;
            $item->write();
        }

        $this->extend('onAfterAssignGroupItems', $list);
        
        // Forward the request to GridFieldOrderableRows::handleReorder (if GridFieldOrderableRows)
        $orderableRowsComponent = $grid->getConfig()->getComponentByType('GridFieldOrderableRows');
        if($orderableRowsComponent) {
            return $orderableRowsComponent->handleReorder($grid, $request);
        } else {
            return $grid->FieldHolder();
        }

	}
public function handleGroupAssignment ( $ grid , $ request ) { $ list = $ grid -> getList ( ) ; // (copied from GridFieldOrderableRows::handleReorder) $ modelClass = $ grid -> getModelClass ( ) ; if ( $ list instanceof ManyManyList && ! singleton ( $ modelClass ) -> canView ( ) ) { $ this -> httpError ( 403 ) ; } else if ( ! ( $ list instanceof ManyManyList ) && ! singleton ( $ modelClass ) -> canEdit ( ) ) { $ this -> httpError ( 403 ) ; } // $ item_id = $ request -> postVar ( 'groupable_item_id' ) ; $ group_key = $ request -> postVar ( 'groupable_group_key' ) ; if ( $ group_key == 'none' ) $ group_key = '' ; $ item = $ list -> byID ( $ item_id ) ; $ groupField = $ this -> getOption ( 'groupField' ) ; // Update item with correct Group assigned (custom query required to write m_m_extraField) //        DB::query(sprintf( //            "UPDATE `%s` SET `%s` = '%s' WHERE `BlockID` = %d", //            'SiteTree_Blocks', //            'BlockArea', //            $group_key, //            $item_id //        )); if ( $ list instanceof ManyManyList && array_key_exists ( $ groupField , $ list -> getExtraFields ( ) ) ) { // update many_many_extrafields (MMList->add() with a new item adds a row, with existing item modifies a row) $ list -> add ( $ item , array ( $ groupField => $ group_key ) ) ; } else { // or simply update the field on the item itself $ item -> $ groupField = $ group_key ; $ item -> write ( ) ; } $ this -> extend ( 'onAfterAssignGroupItems' , $ list ) ; // Forward the request to GridFieldOrderableRows::handleReorder (if GridFieldOrderableRows) $ orderableRowsComponent = $ grid -> getConfig ( ) -> getComponentByType ( 'GridFieldOrderableRows' ) ; if ( $ orderableRowsComponent ) { return $ orderableRowsComponent -> handleReorder ( $ grid , $ request ) ; } else { return $ grid -> FieldHolder ( ) ; } }
Handles requests to assign a new block area to a block item

@param GridField $grid
@param SS_HTTPRequest $request
@return SS_HTTPResponse
Handles requests to assign a new block area to a block item