Bitrix Site Manager

OnBeforeIBlockUpdate

bool
event_handler(
 array &arParams 
);
Fired from CIBlock::Update before the information block is modified. Can be used to decline 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 $APPLICATION->ThrowException() and return false.

See Also

  • OnAfterIBlockUpdate event
  • CIBlock::Update
  • Handling events

    Example

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