nikola_piter
Гуру форума
- Регистрация
- 27 Июн 2007
- Сообщения
- 221
- Реакции
- 95
парни помогите разобраться с этим кодом:
Сам модуль делает, что читает все свойства инфоблока и на основании свойств строит форму. Данный код я так понимаю читает введенные значения в поля формы и записывает в инфоблок. Как вывести на экран эти поля или этот массив?
PHP:
if(is_array($arResult["QUESTIONS"])){
foreach( $arResult["QUESTIONS"] as $FIELD_CODE => $arQuestion ){
if(isset($_REQUEST[$FIELD_CODE])){
$val = !empty( $_REQUEST[$FIELD_CODE] ) ? $_REQUEST[$FIELD_CODE] : $arQuestion["DEFAULT"];
$val = htmlspecialchars($val, (ENT_COMPAT | ENT_HTML401), LANG_CHARSET);
}
elseif($arQuestion["FIELD_TYPE"] === "file"){
$val = $valFile = '';
if($arQuestion["MULTIPLE"] == "Y"){
if($_FILES){
foreach($_FILES as $key => $arFile){
$code = explode('_', $key);
if($code[0] == $FIELD_CODE){
if(strlen($arFile['name'])){
$valFile[$code[1]] = $arFile['name'];
$val .= (strlen($val) ? ', ' : '').$arFile['name'].' ('.($arFile['size'] < 1024 ? $a$
}
}
}
}
}
else{
$arFile = $_FILES[$FIELD_CODE];
if(strlen($arFile['name'])){
$valFile = $arFile['name'];
$val .= (strlen($val) ? ', ' : '').$arFile['name'].' ('.($arFile['size'] < 1024 ? $arFile['size'].GetMessage$
}
}
if(!strlen($val)){
$val = $valFile = $arQuestion["DEFAULT"];
if($arQuestion["MULTIPLE"] == "Y"){
$valFile = array('n0' => $arQuestion["DEFAULT"], 'n1' => $arQuestion["DEFAULT"], 'n2' => $arQuestion["DEFAUL$
}
}
}
$required = $arQuestion["IS_REQUIRED"] == "Y" ? 'required' : '';
$phone = strpos( $arQuestion["CODE"], "PHONE" ) !== false ? 'phone' : '';
$placeholder = $arParams["IS_PLACEHOLDER"] == "Y" ? 'placeholder="'.$arQuestion["NAME"].'"' : '';
$icon = !empty( $arQuestion["ICON"] ) ? '<i class="icon '.$arQuestion["ICON"].'"></i>' : '';
$html = '';
switch( $arQuestion["FIELD_TYPE"] ){
case "text":
$html = '<input type="'.( $arQuestion["CODE"] == "EMAIL" ? "email" : "text" ).'" id="'.$arQuestion["CODE"].'" name="$
break;
case "integer":
$html = '<input type="number" id="'.$arQuestion["CODE"].'" name="'.$arQuestion["CODE"].'" class="form-control '.$req$
break;
case "date":
$html = '<input type="date" id="'.$arQuestion["CODE"].'" name="'.$arQuestion["CODE"].'" class="form-control date '.$$
break;
case "html":
$html = '<textarea id="'.$arQuestion["CODE"].'" rows="3" name="'.$arQuestion["CODE"].'" class="form-control '.$requi$
break;
case "list":
$rsValue = CIBlockProperty::GetPropertyEnum( $arQuestion["CODE"], array( "SORT" => "ASC", "ID" => "ASC" ), array("IB$
$html = '<select id="'.$arQuestion["CODE"].'" name="'.$arQuestion["CODE"].'" class="form-control '.$required.'" '.$p$
while( $arValue = $rsValue->Fetch() ){
$selected = '';
if( !empty( $val ) && $arValue["XML_ID"] == $val ){
$selected = 'selected="selected"';
}
if( empty( $val ) && $arValue["DEF"] == "Y" ){
$selected = 'selected="selected"';
}
$html .= '<option value="'.$arValue["ID"].'" '.$selected.' >'.$arValue["VALUE"].'</option>';
$arResult["QUESTIONS"][$FIELD_CODE]["ENUMS"][$arValue["ID"]] = $arValue["VALUE"];
}
$html .= '</select>'.$icon;
break;
case "checkbox":
$html = '';
$rsValue = CIBlockProperty::GetPropertyEnum( $arQuestion["CODE"], array( "SORT" => "ASC", "ID" => "ASC" ) );
$count = 0;
while( $arValue = $rsValue->Fetch() ){
$count++;
}
$rsValue = CIBlockProperty::GetPropertyEnum( $arQuestion["CODE"], array( "SORT" => "ASC", "ID" => "ASC" ) );
while( $arValue = $rsValue->Fetch() ){
$artmpValue = $arValue;
$checked = '';
if( !empty( $val ) && $arValue["ID"] == $val ){
$checked = 'checked="checked"';
}
if( empty( $val ) && $arValue["DEF"] == "Y" ){
$checked = 'checked="checked"';
}
$html .= '<input class="'.$required.'" id="'.$arValue["ID"].'" name="'.$arQuestion["CODE"].'" type="checkbox$
if( $count == 1 ){
$html .= '<label for="'.$arValue["ID"].'">'.$arQuestion["NAME"].'</label>';
}else{
$html .= '<label for="'.$arValue["ID"].'">'.$arValue["VALUE"].'</label>';
}
}
break;
case "file":
if( $arQuestion["MULTIPLE"] == "Y" ){
$html = '';
for( $i = 0; $i < 4; ++$i ){
$html .= '<input type="file" id="'.$arQuestion["CODE"].'" name="'.$arQuestion["CODE"].'_n'.$i.'" '.$$
}
}else{
$html = '<input type="file" id="'.$arQuestion["CODE"].'" name="'.$arQuestion["CODE"].'" '.$required.' '.$pla$
}
break;
}
$arResult["QUESTIONS"][$FIELD_CODE]["VALUE"] = $val;
$arResult["QUESTIONS"][$FIELD_CODE]["HTML_CODE"] = $html;
}
}
Последнее редактирование: