Description and parameters

 int ID,
array arFields

Method updates description for iblock element fields. By using it you can mark fields as required for completion, as well as to set default value for new elements. Static method.

Note: required fields are checked in the methods CIBlock::Add and CIBlock::Update, and default value is set only in the element edit form in the site's admin section.


Parameter Description
Iblock ID.
Array("field code" => "value" ...), where the value is array containing the following elements:
  • IS_REQUIRED - requirement attribute (Y|N).
  • DEFAULT_VALUE - field default value.

Returned value

Method returns nothing.

See Also

Field description

  • IBLOCK_SECTION - association with section
  • ACTIVE - active status flag
  • ACTIVE_FROM - start date for element action
  • ACTIVE_TO - end date for element action
  • SORT - Sort order for elements
  • NAME - Element name
  • PREVIEW_PICTURE - Image code for preview
  • PREVIEW_TEXT_TYPE - Preview text type
  • PREVIEW_TEXT - Preview text
  • DETAIL_PICTURE - Image code for detailed view.
  • DETAIL_TEXT_TYPE - Detailed description type
  • DETAIL_TEXT - Detailed description
  • XML_ID - External ID
  • CODE - Symbolic ID
  • TAGS - Element tags
Required attribute cannot be redefined for the fields ACTIVE, NAME, PREVIEW_TEXT_TYPE, DETAIL_TEXT_TYPE. These fields are always required.

Field DEFAULT_VALUE value for fields PREVIEW_PICTURE и DETAIL_PICTURE is an array of the following type:
  • FROM_DETAIL - possible values: Y|N. Indicates the requirement for converting preview image from detailed image.
  • SCALE - possible values: Y|N. If equal "Y", the image will be resized.
  • WIDTH - integer. Image size will be updated so its width won't exceed the value of this field.
  • HEIGHT - integer. Image size will be updated so its height won't exceed the values of this field.
  • IGNORE_ERRORS - possible values: Y|N. When errors occur during this image update, generates error with value "N".
  • METHOD - possible values: resample or empty. Field value equal to "resample" results in using resizing feature imagecopyresampled, instead of imagecopyresized. This is more of a qualitative method, but requires more server resources.
  • COMPRESSION - integer from 0 to 100. When value is more than 0, it's used as compression parameter for JPEG images. 100 corresponds to the best quality with larger file size.
  • DELETE_WITH_DETAIL -  possible values: Y|N. Indicates the necessity of deleting an preview image when deleting a details image.
  • UPDATE_WITH_DETAIL -  possible values: Y|N. Indicates the necessity of updating preview image when updating a details image.


//How to make "Symbolic code" field as required
if (CModule::IncludeModule('iblock'))
$Id = 2;
$fields = CIBlock::getFields($Id);
$fields["CODE"]["IS_REQUIRED"] = "Y";
CIBlock::setFields($Id, $fields);
//Additional settings for the "Symbolic code" field
$arFields["CODE"]["DEFAULT_VALUE"]["UNIQUE"] = "Y";//When code is specified, checks for uniqueness
$arFields["CODE"]["DEFAULT_VALUE"]["TRANSLITERATION"] = "Y";//Transliterates from the name when adding an element

//Hint: you can search for settings for all fields in the original html code for iblock edit page.

© «Bitrix24», 2001-2023