Skip to content

Commit

Permalink
Подержка типа свойства "Файл" (resolve #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhikh18 committed Mar 5, 2020
1 parent d2adcd6 commit 8c2b9b6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 21 additions & 1 deletion install/components/opensource/order/class.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,26 @@ public function createVirtualOrder(int $personTypeId)
return $this->order;
}

public function getPropertiesFromRequest()
{
$properties = $this->request['properties'] ?? $this->arParams['DEFAULT_PROPERTIES'] ?? [];
$arFileProperties = $this->request->getFileList()->get('properties');

if (is_array($arFileProperties)) {
foreach ($arFileProperties as $fileKey => $arFileField) {
foreach ($arFileField as $fieldCode => $arFileFieldValue) {
if( ! isset($properties[$fieldCode])) {
$properties[$fieldCode] = array("ID" => '');
}

$properties[$fieldCode][$fileKey] = current($arFileFieldValue);
}
}
}

return $properties;
}

/**
* @param array $propertyValues
* @throws Exception
Expand Down Expand Up @@ -374,7 +394,7 @@ public function executeComponent()
try {
$this->createVirtualOrder($this->arParams['PERSON_TYPE_ID']);

$propertiesList = $this->request['properties'] ?? $this->arParams['DEFAULT_PROPERTIES'] ?? [];
$propertiesList = $this->getPropertiesFromRequest();
if (!empty($propertiesList)) {
$this->setOrderProperties($propertiesList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@

default:
?>
<input id="<?= $arProp['FORM_LABEL'] ?>" type="text"
<input id="<?= $arProp['FORM_LABEL'] ?>"
type="<?= 'FILE' === $arProp['TYPE'] ? 'file' : 'text' ?>"
name="<?= $arProp['FORM_NAME'] ?>"
value="<?= $arProp['VALUE'] ?>">
<? endswitch; ?>
Expand Down

0 comments on commit 8c2b9b6

Please sign in to comment.