Answer the question
In order to leave comments, you need to log in
How to add an infoblock element with a file ID to DETAIL_PICTURE?
Hello! When adding an element via CIBlockElement::Add(), it crashes if you set DETAIL_PICTURE to the image id or CFile::GetFileArray($id);
In the first and second cases, it returns "The required field "Detailed picture" is not filled.". How to add correctly?
Answer the question
In order to leave comments, you need to log in
Offhand:
It works. I was not too lazy and checked:
$dbElement = CIBlockElement::GetList(array('ID' => 'DESC'), array('IBLOCK_ID' => 23));
while($aElem = $dbElement->Fetch()) {
var_dump($aElem);
};
$dbElem = new CIBlockElement;
var_dump($dbElem->Add(
array(
"NAME" => 'Test2',
"IBLOCK_ID" => 23,
'ACTIVE' => 'Y',
'PREVIEW_TEXT' => 'текст для списка элементов',
//'DETAIL_PICTURE' => CFile::MakeFileArray(545)
)
));
var_dump($dbElem->Add(
array(
"NAME" => 'Test3',
"IBLOCK_ID" => 23,
'ACTIVE' => 'Y',
'PREVIEW_TEXT' => 'текст для списка элементов',
'DETAIL_PICTURE' => CFile::MakeFileArray(545)
)
));
1. First, uncheck the corresponding checkbox in the IB settings and check again (to exclude kernel glitches).
2. Make an empty file (without connecting the site template) in which there will be only CIBlockElement::Add with the addition of an image, let the image lie in the root of the site with the correct file system rights (for accuracy, let everyone have read rights)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question