Documentation

OnBeforeIBlockAdd

bool
event_handler(
   array &arParams 
);
The event OnBeforeIBlockAdd is fired from CIBlock::Add before adding a new information block. Can be used to cancel the operation or to redefine fields.

Parameters

ParameterDescription
arParams An array of the new information block 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 operation and terminate CIBlock::Add, throw an exception by calling ThrowException() and return false.

See Also

  • [link=9207881]OnAfterIBlockAdd event[/link]
  • CIBlock::Add

    Example

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