D
D
drewandrew2020-07-13 19:20:17
1C-Bitrix
drewandrew, 2020-07-13 19:20:17

How to pass the product name in Bitrix to the form result?

How to pass the name of the product on the page of which it is located to the form result? I am using the web form component.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-07-13
@drewandrew

1. In the admin panel Settings-->Modules settings-->Web forms, uncheck "Use simplified form editing mode" so that the fields can be assigned a symbolic code.
2. In the settings of your web form, you create a "question", for example, "Product name", with the symbolic code ELEMENT_NAME, add an "answer" field type hidden
3. Add a parameter to the call of the web form component, for example like this

"ELEMENT_NAME" => array(
  "VALUE" => $arResult["NAME"],
  "AUTOCOMPLETE" => "Y"
)

4. In the form output template where there is a cycle of questions
foreach ($arResult["QUESTIONS"] as $FIELD_SID => $arQuestion)
  {

inside you add
if(isset($arParams[$FIELD_SID]) && $arParams[$FIELD_SID]['VALUE'] && $arParams[$FIELD_SID]['AUTOCOMPLETE'] == 'Y') {
  $arQuestion['HTML_CODE'] = str_replace('name=', 'value="'.$arParams[$FIELD_SID]['VALUE'].'" name=', $arQuestion['HTML_CODE']);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question