Documentation

OnBeforeIBlockElementAdd

bool
event_handler(
   array &arParams 
);
The event OnBeforeIBlockElementAdd is fired from CIBlockElement:Add before the new information block is added. Can be used to cancel the operation 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.

Returned value

To cancel operation and terminate CIBlockElement:Add, throw an exception by calling ThrowException() and returns false.

See Also

  • OnAfterIBlockElementAdd event
  • CIBlockElement:Add

    Example

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