diff --git a/templates/form/field/UserField/edit.php b/templates/form/field/UserField/edit.php new file mode 100644 index 0000000..e9580fb --- /dev/null +++ b/templates/form/field/UserField/edit.php @@ -0,0 +1,29 @@ +module()->getDir() . '/templates/admin_bitrix_assets.php'; + +global $USER_FIELD_MANAGER; +/** @var UserFieldEntity $propertyEntity */ +$propertyEntity = $field->getPropertyEntity(); +$property_fields = $propertyEntity->getRaw(); +$arUserField['EDIT_FORM_LABEL'] = $property_fields['EDIT_FORM_LABEL']?: $property_fields['FIELD_NAME']; +$property_fields['USER_TYPE'] = $propertyEntity->getUserTypeBuild(); +$property_fields['VALUE'] = $field->getValue(); + +if($field->isNew()){ + $property_fields['VALUE'] = $field->getPropertyEntity()->getDefaultValue(); +} +$property_fields['ENTITY_VALUE_ID'] = $property_fields['VALUE_ID'] = $field->getParentEntityId(); + +//$arUserFields = $USER_FIELD_MANAGER->GetUserFields($field->getPropertyEntity()->getRaw('ENTITY_ID'), $property_fields['ENTITY_VALUE_ID'], LANGUAGE_ID); +//pre($arUserFields[$propertyEntity->getCode()]['VALUE']); + +echo $USER_FIELD_MANAGER->GetEditFormHTML(false, $field->getValue(), $property_fields); diff --git a/templates/form/field/UserField/filter.php b/templates/form/field/UserField/filter.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/templates/form/field/UserField/filter.php @@ -0,0 +1 @@ +module()->getDir() . '/templates/admin_bitrix_assets.php'; + +$propertyEntity = $field->getPropertyEntity(); + +?> + + getLabel()?> + getPropertyValue()->getRestoredValue(); + $extValues = []; + if($field->isMultiple()){ + foreach ($restoredValue['VALUE'] as $k => $v){ + if($v){ + $extValues[$k] = ['VALUE' => $v, 'DESCRIPTION' => (string)$restoredValue['DESCRIPTION'][$k]]; + } + } + } else { + if($restoredValue['VALUE']){ + $extValues[] = ['VALUE' => $restoredValue['VALUE'], 'DESCRIPTION' => (string)$restoredValue['DESCRIPTION']]; + } + } + + + if($field->isMultiple() ){ + $shortValues = $field->getValue(); + } else { + $shortValues = []; + $value = $field->getValue(); + if(mb_strlen($value)){ + $shortValues = (array)$value; + } + } + + + if($propertyEntity->isWithDescription()) { + $values = $extValues; + } else { + $values = $shortValues; + } + + $property_fields = $propertyEntity->getRaw(); + $property_fields['USER_TYPE_SETTINGS'] = $propertyEntity->getSettings(); + + if($propertyEntity->getUserType()){ + $property_fields['VALUE'] = $shortValues; + $property_fields['~VALUE'] = $extValues; + } + unset($property_fields['USER_TYPE_SETTINGS_LIST']); + + _ShowPropertyField( + $field->getName(), + $property_fields, + $values, + $field->isNew(), + false, + 50000, + $field->getForm()->getName(), + false + ); + ?> + diff --git a/templates/form/field/iBlockProperty/filter.php b/templates/form/field/iBlockProperty/filter.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/templates/form/field/iBlockProperty/filter.php @@ -0,0 +1 @@ +addJs('/bitrix/js/iblock/iblock_edit.js'); -Asset::getInstance()->addJs("/bitrix/js/main/core/core.js"); -\Bitrix\Main\UI\Extension::load(array("popup", "ajax", "ui.buttons", "ui.forms", "main.polyfill.core", "color_picker")); -$bLabel = mb_strlen($field->getLabel()); -$labelAttrs = []; -if(mb_strlen($field->getId())){ - $labelAttrs['for'] = $field->getId(); -} -if($bLabel){?>getAttributes(); -$inputAttributes['data-dirty'] = $field->isDirty()?'true':'false'; -if($field->isMultiple()){ - $inputAttributes['name'] = preg_replace('/\[]$/', '', $inputAttributes['name']) . '[]'; -} -unset($inputAttributes['options']); - -_ShowPropertyField($field->getName(), $field->getPropertyEntity()->getRaw(), [], false, false, 50000, $field->getForm()->getName(), false); -echo "\n\r"; \ No newline at end of file diff --git a/templates/form/field/input.php b/templates/form/field/input.php deleted file mode 100644 index e21a9d6..0000000 --- a/templates/form/field/input.php +++ /dev/null @@ -1,18 +0,0 @@ -getLabel()); -$labelAttrs = []; -if(mb_strlen($field->getId())){ - $labelAttrs['for'] = $field->getId(); -} -if($bLabel){?>getAttributes(); -$inputAttributes['data-dirty'] = $field->isDirty()?'true':'false'; - - ?>>getLabel()); +$labelAttrs = []; +if(mb_strlen($field->getId())){ + $labelAttrs['for'] = $field->getId(); +} +if($bLabel){?>isMultiple()){ + foreach ($field->getValue() as $value){ + $inputAttributes = $field->getAttributes(); + $inputAttributes['name'] .= '[]'; + $inputAttributes['value'] = $value; + ?>>getAttributes(); + $inputAttributes['name'] .= '[]'; + $inputAttributes['value'] = ''; + ?>>getAttributes(); + $inputAttributes['data-dirty'] = $field->isDirty()?'true':'false'; + ?>>