Bitrix Site Manager

OnBeforeIBlockElementUpdate

bool
event_handler(
   array &arParams 
);
Fired from CIBlockElement::Update before the information block element is modified. Can be used to cancel modification or to redefine fields.

Parameters

ParameterDescription
arParams An array of the new information block element fields.

Note
The parameter(s) of this handler are references to the original variables. Hence, altering their values from within the handler causes changing values of the source variables passed to the handler.

Return Values

To cancel the update and terminate CIBlockElement::Update, throw an exception by calling $APPLICATION->ThrowException() and return false.

See Also

  • OnAfterIBlockElementUpdate event
  • CIBlockElement::Update
  • Handling events

    Example

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