Documentation

SetInputDefaultValue

void
CFormOutput::SetInputDefaultValue(
 string $FIELD_SID,
 mixed $value [,
 mixed $ANSWER_ID = false] 
);

The method sets value by default for a web form field. This method is used only with the web form visual template. Non-static method.

Method parameters

Parameter Description
FIELD_SID Question string ID.
value Reply value (or reply ID for questions with reply options (radio, checkbox, multiselect, dropdown)). Array of IDs can be passed for types of questions that have multiple selection (checkbox, multiselect).
ANSWER_ID Optional parameter. Array of reply IDs or a single reply ID (used for multiple fields).

Examples of use

// used in the form.result.new component

$FORM = new CFormOutput();
$FORM->InitializeTemplate($arParams, $arResult);

/* .............. */ 

$FORM->setInputDefaultValue('MY_TEXT_FIELD', $USER->GetFullName()); // for simple strings

$FORM->setInputDefaultValue('MY_CHECKBOX_FIELD', "Y", array(1114, 1115)); // for checkbox or multiselect.
// or $FORM->setInputDefaultValue('MY_CHECKBOX_FIELD', array(1114, 1115)); 

$FORM->setInputDefaultValue('MY_RADIO_FIELD', "Y", 1103); // for radio 
// or $FORM->setInputDefaultValue('MY_RADIO_FIELD', 1103); 

// 1103-1115 - reply IDs.

/* .............. */ 
$strReturn = $FORM->IncludeFormCustomTemplate() 


© «Bitrix24», 2001-2024
Up