S
S
Surzhenko2019-02-11 03:30:55
1C-Bitrix
Surzhenko, 2019-02-11 03:30:55

How to create a form for adding elements to an infoblock using the Bitrix API?

It is necessary to add the "order in 1 click" button, which calls the form with the "phone" field, the result of the work of the form is to add an element to the new "quick orders" iblock.
That is, you need to make a regular form, in which there will be a field for the phone, a name and a hidden field with the name of the product.
Make a separate Infoblock in Bitrix called "Order in 1 click".
In the form handler, you need to programmatically create elements in the infoblock in which to write the Name, Phone and Product Name.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jupiter Max, 2019-02-11
@vardoLP

use the Add
method 1. Create an infoblock
2. Enter the required fields into the array in the handler (from the infoblock)

$el = new CIBlockElement; // подключаем класс для работы с инфоблоками
$iblock_id = 2; // тут id вашего инфоблока

$arFieldsSec = array(
'IBLOCK_ID'=>$iblock_id, // id инфоблока
'NAME' => $name // тут к примеру POST переменная name. NAME это название поля в инфоблоке
);

// ну и добавляем через метод
$el->Add($arFieldsSec);

This is a primitive example.
Everything should be clear in the documentation.

K
Kudis, 2019-02-11
@kudis

You can use the standard component iblock.element.add.form
It does exactly what you described

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question