Skip to content

Commit

Permalink
Подержка типа свойства "Файл" (resolve #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhikh18 committed Mar 30, 2020
1 parent 427a503 commit 5188a1f
Show file tree
Hide file tree
Showing 2 changed files with 30 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'] ?? [];
$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" => '');
}
// @todo Multiple property
$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() ?: $this->arParams['DEFAULT_PROPERTIES'] ?? [];
if (!empty($propertiesList)) {
$this->setOrderProperties($propertiesList);
}
Expand Down
10 changes: 9 additions & 1 deletion install/components/opensource/order/templates/.default/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/** @var OpenSourceOrderComponent $component */

?>
<form action="" method="post" name="os-order-form" id="os-order-form">
<form action="" method="post" name="os-order-form" id="os-order-form" enctype="multipart/form-data">

<input type="hidden" name="person_type_id" value="<?=$arParams['PERSON_TYPE_ID']?>">

Expand Down Expand Up @@ -90,6 +90,14 @@
<?
break;

case 'FILE':
?>
<input id="<?= $arProp['FORM_LABEL'] ?>" type="file"
name="<?= $arProp['FORM_NAME'] ?>"
value="<?= $arProp['VALUE'] ?>">
<?
break;

default:
?>
<input id="<?= $arProp['FORM_LABEL'] ?>" type="text"
Expand Down

0 comments on commit 5188a1f

Please sign in to comment.