Documentation

OnBeforeIBlockUpdate

bool
event_handler(
 array &arParams 
);
The event OnBeforeIBlockUpdate is fired from CIBlock::Update before the information block is modified. Can be used to cancel modifying a block or to redefine fields.

Parameters

ParameterDescription
arParams An array of fields of the information block to be updated.

Note
The parameter of this handler is a reference to the original variable. Hence, altering the value(s) from within the handler causes changing values of the source variable passed to the handler.

Return Values

To cancel the information block update and terminate the method CIBlock::Update, throw an exception by calling ThrowException() and return false.

See Also

  • OnAfterIBlockUpdate event
  • CIBlock::Update

    Example

     
    <?
    // file /bitrix/php_interface/init.php
    // register handler
    AddEventHandler("iblock", 
                    "OnBeforeIBlockUpdate", 
                    Array("MyClass", "OnBeforeIBlockUpdateHandler"));
    
    class MyClass
    {
        // create handler for "OnBeforeIBlockUpdate"
        public static function OnBeforeIBlockUpdateHandler(&$arFields)
        {
            if(strlen($arFields["CODE"])<=0)
            {
                global $APPLICATION;
                $APPLICATION->throwException("Enter the mnemonic code. (ID:".$arFields["ID"].")");
                return false;
            }
        }
    }
    ?>
  • © «Bitrix24», 2001-2024
    Up