Documentation

EditAction

bool
CAdminList::EditAction(
)

The EditAction method returns true if table rows have been edited and changes need to be saved.

Example

// save modified elements
if($lAdmin->EditAction() && $POST_RIGHT=="W")
{
    // walk the list of passed elements
    foreach($FIELDS as $ID=>$arFields)
    {
        // if the elements are not changed - do nothing
        if(!$lAdmin->EditAction($ID))
            continue;

        // save changes of each element
        $DB->StartTransaction();
        $ID = IntVal($ID);
        $cData = new CRubric;
        if(($rsData = $cData->GetByID($ID)) && ($arData = $rsData->Fetch()))
        {
            foreach($arFields as $key=>$value)
                $arData[$key]=$value;
            if(!$cData->Update($ID, $arData))
            {
                $lAdmin->AddGroupError(GetMessage("rub_save_error")." ".$cData->LAST_ERROR, $ID);
                $DB->Rollback();
            }
        }
        else
        {
            $lAdmin->AddGroupError(GetMessage("rub_save_error")." ".GetMessage("rub_no_rubric"), $ID);
            $DB->Rollback();
        }
        $DB->Commit();
    }
}
© «Bitrix24», 2001-2024