Вызов компонента
<?$APPLICATION->IncludeComponent(
"bitrix:main.profile",
"flat",
Array(
"CHECK_RIGHTS" => "N",
"SEND_INFO" => "N",
"SET_TITLE" => "Y",
"USER_PROPERTY" => array(),
"USER_PROPERTY_NAME" => ""
)
);?>
template.php
<?php
use Bitrix\Main\Web\Json;
/**
* @global CMain $APPLICATION
* @var array $arParams
* @var array $arResult
*/
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
if (isset($arResult["SHOW_SMS_FIELD"]) && $arResult["SHOW_SMS_FIELD"] == true) {
CJSCore::Init('phone_auth');
}
?>
<div class="auth-form profile-form">
<div class="container">
<div class="auth-form__inner">
<? if (!empty($arResult["strProfileError"])): ?>
<div class="auth-form__errors">
<div class="auth-form__error"><?=$arResult["strProfileError"]?></div>
</div>
<? endif; ?>
<?
if (isset($arResult['DATA_SAVED']) && $arResult['DATA_SAVED'] == 'Y') {
?>
<div class="auth-form__success">
<div class="auth-form__success-message"><?=GetMessage('PROFILE_DATA_SAVED')?></div>
</div>
<?
}
?>
<? if (isset($arResult["SHOW_SMS_FIELD"]) && $arResult["SHOW_SMS_FIELD"] == true): ?>
<form method="post" action="<?=$arResult["FORM_TARGET"]?>" class="auth-form__form">
<?=$arResult["BX_SESSION_CHECK"]?>
<input type="hidden" name="lang" value="<?=LANG?>"/>
<input type="hidden" name="ID" value="<?=$arResult["ID"]?>"/>
<input type="hidden" name="SIGNED_DATA" value="<?=htmlspecialcharsbx($arResult["SIGNED_DATA"])?>"/>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="sms_code">
<? echo GetMessage("main_profile_code") ?><span class="starrequired">*</span>
</label>
<input
type="text"
id="sms_code"
name="SMS_CODE"
value="<?=htmlspecialcharsbx($arResult["SMS_CODE"])?>"
autocomplete="off"
class="form-control auth-form__input"
placeholder="Введите код из SMS"
/>
</div>
<div class="auth-form__submit">
<button type="submit" name="code_submit_button" class="btn auth-form__submit-btn">
<? echo GetMessage("main_profile_send") ?>
</button>
</div>
</form>
<script>
new BX.PhoneAuth({
containerId: 'bx_profile_resend',
errorContainerId: 'bx_profile_error',
interval: <?= $arResult["PHONE_CODE_RESEND_INTERVAL"] ?>,
data: <?= Json::encode([
'signedData' => $arResult["SIGNED_DATA"],
]) ?>,
onError: function (response) {
var errorDiv = BX('bx_profile_error');
var errorNode = BX.findChildByClassName(errorDiv, 'errortext');
errorNode.innerHTML = '';
for (var i = 0; i < response.errors.length; i++) {
errorNode.innerHTML = errorNode.innerHTML + BX.util.htmlspecialchars(response.errors[i].message) + '<br>';
}
errorDiv.style.display = '';
}
});
</script>
<div id="bx_profile_error" style="display:none"><? ShowError("error") ?></div>
<div id="bx_profile_resend"></div>
<? else: ?>
<script>
var opened_sections = [<?
$arResult["opened"] = $_COOKIE[$arResult["COOKIE_PREFIX"] . "_user_profile_open"] ?? '';
$arResult["opened"] = preg_replace("/[^a-z0-9_,]/i", "", $arResult["opened"]);
if ($arResult["opened"] <> '') {
echo "'" . implode("', '", explode(",", $arResult["opened"])) . "'";
} else {
$arResult["opened"] = "reg";
echo "'reg'";
}
?>];
var cookie_prefix = '<?= $arResult["COOKIE_PREFIX"] ?>';
</script>
<form method="post" name="form1" action="<?=$arResult["FORM_TARGET"]?>" enctype="multipart/form-data"
class="auth-form__form">
<?=$arResult["BX_SESSION_CHECK"]?>
<input type="hidden" name="lang" value="<?=LANG?>"/>
<input type="hidden" name="ID" value="<?=$arResult["ID"]?>"/>
<!-- Основная информация -->
<div class="profile-section">
<div class="profile-section__header">
<button type="button" class="profile-section__toggle" onclick="SectionClick('reg')">
<span class="profile-section__title"><?=GetMessage("REG_SHOW_HIDE")?></span>
<span class="profile-section__icon">▼</span>
</button>
</div>
<div class="profile-section__content <?=!str_contains($arResult["opened"], "reg")
? "profile-section__content--hidden" : ""?>" id="user_div_reg">
<?
if ($arResult["ID"] > 0) {
?>
<?
if ($arResult["arUser"]["TIMESTAMP_X"] <> '') {
?>
<div class="profile-info">
<div class="profile-info__item">
<span class="profile-info__label"><?=GetMessage('LAST_UPDATE')?>:</span>
<span
class="profile-info__value"><?=$arResult["arUser"]["TIMESTAMP_X"]?></span>
</div>
</div>
<?
}
?>
<?
if ($arResult["arUser"]["LAST_LOGIN"] <> '') {
?>
<div class="profile-info">
<div class="profile-info__item">
<span class="profile-info__label"><?=GetMessage('LAST_LOGIN')?>:</span>
<span
class="profile-info__value"><?=$arResult["arUser"]["LAST_LOGIN"]?></span>
</div>
</div>
<?
}
?>
<?
}
?>
<div class="profile-fields">
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="TITLE">
<? echo GetMessage("main_profile_title") ?>
</label>
<input
type="text"
id="TITLE"
name="TITLE"
value="<?=$arResult["arUser"]["TITLE"]?>"
class="form-control auth-form__input"
placeholder="Обращение"
/>
</div>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="NAME">
<?=GetMessage('NAME')?>
</label>
<input
type="text"
id="NAME"
name="NAME"
maxlength="50"
value="<?=$arResult["arUser"]["NAME"]?>"
class="form-control auth-form__input"
placeholder="Имя"
/>
</div>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="LAST_NAME">
<?=GetMessage('LAST_NAME')?>
</label>
<input
type="text"
id="LAST_NAME"
name="LAST_NAME"
maxlength="50"
value="<?=$arResult["arUser"]["LAST_NAME"]?>"
class="form-control auth-form__input"
placeholder="Фамилия"
/>
</div>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="SECOND_NAME">
<?=GetMessage('SECOND_NAME')?>
</label>
<input
type="text"
id="SECOND_NAME"
name="SECOND_NAME"
maxlength="50"
value="<?=$arResult["arUser"]["SECOND_NAME"]?>"
class="form-control auth-form__input"
placeholder="Отчество"
/>
</div>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="LOGIN">
<?=GetMessage('LOGIN')?><span class="starrequired">*</span>
</label>
<input
type="text"
id="LOGIN"
name="LOGIN"
maxlength="50"
value="<?=$arResult["arUser"]["LOGIN"]?>"
class="form-control auth-form__input"
placeholder="Логин"
/>
</div>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="EMAIL">
<?=GetMessage('EMAIL')?><? if ($arResult["EMAIL_REQUIRED"]): ?><span
class="starrequired">*</span><? endif ?>
</label>
<input
type="email"
id="EMAIL"
name="EMAIL"
maxlength="50"
value="<?=$arResult["arUser"]["EMAIL"]?>"
class="form-control auth-form__input"
placeholder="Введите email"
/>
</div>
<? if ($arResult["PHONE_REGISTRATION"]): ?>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="PHONE_NUMBER">
<? echo GetMessage(
"main_profile_phone_number"
) ?><? if ($arResult["PHONE_REQUIRED"]): ?><span
class="starrequired">*</span><? endif ?>
</label>
<input
type="text"
id="PHONE_NUMBER"
name="PHONE_NUMBER"
maxlength="50"
value="<?=$arResult["arUser"]["PHONE_NUMBER"]?>"
class="form-control auth-form__input _mask_phone"
placeholder="+7 (000) 000-00-00"
/>
</div>
<? endif ?>
<? if ($arResult['CAN_EDIT_PASSWORD']): ?>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="NEW_PASSWORD">
<?=GetMessage('NEW_PASSWORD_REQ')?>
</label>
<div class="auth-form__password-wrapper">
<? if ($arResult["SECURE_AUTH"]): ?>
<div class="auth-form__secure-note" id="bx_auth_secure"
style="display:none">
<div class="ui-note">
<span class="auth-form__secure-icon">🔒</span>
<? echo GetMessage("AUTH_SECURE_NOTE") ?>
</div>
</div>
<script>
document.getElementById('bx_auth_secure').style.display = '';
</script>
<? endif ?>
<input
type="password"
id="NEW_PASSWORD"
name="NEW_PASSWORD"
maxlength="50"
value=""
autocomplete="off"
class="form-control auth-form__input"
placeholder="Новый пароль"
/>
</div>
</div>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="NEW_PASSWORD_CONFIRM">
<?=GetMessage('NEW_PASSWORD_CONFIRM')?>
</label>
<input
type="password"
id="NEW_PASSWORD_CONFIRM"
name="NEW_PASSWORD_CONFIRM"
maxlength="50"
value=""
autocomplete="off"
class="form-control auth-form__input"
placeholder="Повторите новый пароль"
/>
</div>
<? endif ?>
<? if ($arResult["TIME_ZONE_ENABLED"] == true): ?>
<div class="profile-subsection">
<h4 class="profile-subsection__title"><? echo GetMessage(
"main_profile_time_zones"
) ?></h4>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="AUTO_TIME_ZONE">
<? echo GetMessage("main_profile_time_zones_auto") ?>
</label>
<select
name="AUTO_TIME_ZONE"
id="AUTO_TIME_ZONE"
class="form-control auth-form__input"
onchange="this.form.TIME_ZONE.disabled=(this.value != 'N')"
>
<option value=""><? echo GetMessage(
"main_profile_time_zones_auto_def"
) ?></option>
<option value="Y"<?=($arResult["arUser"]["AUTO_TIME_ZONE"] == "Y"
? ' selected' : '')?>><? echo GetMessage(
"main_profile_time_zones_auto_yes"
) ?></option>
<option value="N"<?=($arResult["arUser"]["AUTO_TIME_ZONE"] == "N"
? ' selected' : '')?>><? echo GetMessage(
"main_profile_time_zones_auto_no"
) ?></option>
</select>
</div>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="TIME_ZONE">
<? echo GetMessage("main_profile_time_zones_zones") ?>
</label>
<select
name="TIME_ZONE"
id="TIME_ZONE"
class="form-control auth-form__input"
<?=($arResult["arUser"]["AUTO_TIME_ZONE"] <> "N" ? 'disabled' : '')?>
>
<? foreach ($arResult["TIME_ZONE_LIST"] as $tz_id => $tz_name): ?>
<option value="<?=$tz_id?>"<?=($arResult["arUser"]["TIME_ZONE"]
== $tz_id ? ' selected' : '')?>><?=$tz_name?></option>
<? endforeach; ?>
</select>
</div>
</div>
<? endif ?>
</div>
</div>
</div>
<!-- Пользовательские свойства -->
<? if ($arResult["USER_PROPERTIES"]["SHOW"] == "Y"): ?>
<div class="profile-section">
<div class="profile-section__header">
<button type="button" class="profile-section__toggle"
onclick="SectionClick('user_properties')">
<span class="profile-section__title"><?=GetMessage("USER_TYPE_EDIT_TAB")?></span>
<span class="profile-section__icon">▼</span>
</button>
</div>
<div
class="profile-section__content <?=!str_contains($arResult["opened"], "user_properties")
? "profile-section__content--hidden" : ""?>" id="user_div_user_properties">
<div class="profile-fields profile-fields__properties">
<? foreach ($arResult["USER_PROPERTIES"]["DATA"] as $FIELD_NAME => $arUserField): ?>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="<?=$FIELD_NAME?>">
<?=$arUserField["EDIT_FORM_LABEL"] ? $arUserField["EDIT_FORM_LABEL"]
: $arUserField["FIELD_NAME"]?>
<? if ($arUserField["MANDATORY"] == "Y"): ?>
<span class="starrequired">*</span>
<? endif ?>
</label>
<? if ($arUserField["USER_TYPE"]["USER_TYPE_ID"] == "file"): ?>
<div class="profile-file-field">
<? if ($arUserField["VALUE"]): ?>
<div class="profile-file-current">
<span class="profile-file-label">Текущий файл:</span>
<? $file = CFile::GetFileArray($arUserField["VALUE"]); ?>
<? if ($file): ?>
<a href="<?=$file["SRC"]?>" target="_blank"
class="profile-file-link">
<?=$file["ORIGINAL_NAME"]?> (<?=CFile::FormatSize(
$file["FILE_SIZE"]
)?>)
</a>
<? endif ?>
</div>
<? endif ?>
<input
type="file"
id="<?=$FIELD_NAME?>"
name="<?=$FIELD_NAME?>"
class="form-control auth-form__input auth-form__input--file"
/>
</div>
<? elseif ($arUserField["USER_TYPE"]["USER_TYPE_ID"] == "boolean"): ?>
<label class="ui-checkbox-label">
<input
type="checkbox"
name="<?=$FIELD_NAME?>"
value="1"
<?=($arUserField["VALUE"] == "1" ? 'checked' : '')?>
/>
<span class="ui-checkbox"></span>
<span class="ui-checkbox-text"><?=$arUserField["SETTINGS"]["LABEL"][1]
??
'Да'?></span>
</label>
<? elseif ($arUserField["USER_TYPE"]["USER_TYPE_ID"] == "enumeration"): ?>
<? if ($arUserField["MULTIPLE"] == "Y"): ?>
<? foreach ($arUserField["USER_TYPE"]["FIELDS"] as $value => $label): ?>
<label class="ui-checkbox-label">
<input
type="checkbox"
name="<?=$FIELD_NAME?>[]"
value="<?=$value?>"
<?=(in_array($value, (array) $arUserField["VALUE"])
? 'checked' : '')?>
/>
<span class="ui-checkbox"></span>
<span class="ui-checkbox-text"><?=$label?></span>
</label>
<? endforeach ?>
<? else: ?>
<select
name="<?=$FIELD_NAME?>"
id="<?=$FIELD_NAME?>"
class="form-control auth-form__input"
>
<option value="">Выберите значение</option>
<? foreach ($arUserField["USER_TYPE"]["FIELDS"] as $value => $label): ?>
<option value="<?=$value?>" <?=($arUserField["VALUE"] == $value
? 'selected' : '')?>>
<?=$label?>
</option>
<? endforeach ?>
</select>
<? endif ?>
<? elseif ($arUserField["USER_TYPE"]["USER_TYPE_ID"] == "datetime"): ?>
<input
type="datetime-local"
id="<?=$FIELD_NAME?>"
name="<?=$FIELD_NAME?>"
value="<?=$arUserField["VALUE"] ? date(
'Y-m-d\TH:i',
strtotime($arUserField["VALUE"])
) : ''?>"
class="form-control auth-form__input"
/>
<? elseif (
$arUserField["USER_TYPE"]["USER_TYPE_ID"] == "string"
&& $arUserField["MULTIPLE"] == "Y"
): ?>
<? foreach ((array) $arUserField["VALUE"] as $i => $value): ?>
<input
type="text"
id="<?=$FIELD_NAME?>_<?=$i?>"
name="<?=$FIELD_NAME?>[]"
value="<?=htmlspecialcharsbx($value)?>"
class="form-control auth-form__input"
placeholder="<?=$arUserField["EDIT_FORM_LABEL"]?>"
style="<?=$i > 0 ? 'margin-top: 8px;' : ''?>"
/>
<? endforeach ?>
<button type="button" class="btn-link profile-add-field"
onclick="addMultipleField('<?=$FIELD_NAME?>')">
+ Добавить еще
</button>
<? else: ?>
<? if (
$arUserField["USER_TYPE"]["USER_TYPE_ID"] == "string"
&& $arUserField["SETTINGS"]["ROWS"] > 1
): ?>
<textarea
id="<?=$FIELD_NAME?>"
name="<?=$FIELD_NAME?>"
rows="<?=$arUserField["SETTINGS"]["ROWS"]?>"
class="form-control auth-form__input"
placeholder="<?=$arUserField["EDIT_FORM_LABEL"]?>"
><?=htmlspecialcharsbx($arUserField["VALUE"])?></textarea>
<? else: ?>
<input
type="text"
id="<?=$FIELD_NAME?>"
name="<?=$FIELD_NAME?>"
value="<?=htmlspecialcharsbx($arUserField["VALUE"])?>"
class="form-control auth-form__input"
placeholder="<?=$arUserField["EDIT_FORM_LABEL"]?>"
/>
<? endif ?>
<? endif ?>
<? if ($arUserField["HELP_MESSAGE"]): ?>
<div class="profile-field-help">
<?=$arUserField["HELP_MESSAGE"]?>
</div>
<? endif ?>
</div>
<? endforeach ?>
</div>
</div>
</div>
<? endif ?>
<div class="auth-form__submit">
<input type="submit" class="btn auth-form__submit-btn" name="save"
value="<?=(($arResult["ID"] > 0) ? GetMessage("MAIN_SAVE") : GetMessage("MAIN_ADD"))?>">
<input type="reset" class="btn btn-outline auth-form__reset-btn" value="<?=GetMessage('MAIN_RESET')?>">
<a class="btn btn-outline auth-form__logout-btn" href="/?logout=yes&<?=bitrix_sessid_get()?>">
Выйти
</a>
</div>
</form>
<? endif ?>
</div>
</div>
</div>
<script>
function addMultipleField(fieldName) {
var container = document.querySelector('[name="' + fieldName + '[]"]:last-of-type').parentNode;
var lastInput = container.querySelector('[name="' + fieldName + '[]"]:last-of-type');
var newInput = lastInput.cloneNode(true);
newInput.value = '';
newInput.style.marginTop = '8px';
container.insertBefore(newInput, container.querySelector('.profile-add-field'));
}
</script>
script.js
function SectionClick(section_id) {
const content = document.getElementById('user_div_' + section_id);
const toggle = content.previousElementSibling.querySelector('.profile-section__toggle');
if (content.classList.contains('profile-section__content--hidden')) {
content.classList.remove('profile-section__content--hidden');
content.classList.add('profile-section__content--shown');
toggle.setAttribute('aria-expanded', 'true');
// Добавляем секцию в opened
if (opened_sections.indexOf(section_id) === -1) {
opened_sections.push(section_id);
}
} else {
content.classList.add('profile-section__content--hidden');
content.classList.remove('profile-section__content--shown');
toggle.setAttribute('aria-expanded', 'false');
// Убираем секцию из opened
const index = opened_sections.indexOf(section_id);
if (index > -1) {
opened_sections.splice(index, 1);
}
}
// Сохранение состояния в cookie
const date = new Date();
date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
document.cookie = cookie_prefix + "_user_profile_open=" + opened_sections.join(',') + "; expires=" + date.toUTCString() + "; path=/";
}
CSS
.profile-form .auth-form__inner {
max-width: 600px;
}
.auth-form__success {
margin-bottom: 20px;
}
.auth-form__success-message {
background-color: rgba(74, 157, 126, 0.1);
border: 1px solid var(--green);
border-radius: 6px;
padding: 12px 16px;
color: var(--green);
font-size: 14px;
}
.profile-section {
margin-bottom: 30px;
}
.profile-section__header {
margin-bottom: 20px;
}
.profile-section__toggle {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 12px 16px;
background-color: var(--gray-10);
border: 1px solid var(--gray-30);
border-radius: 6px;
cursor: pointer;
transition: var(--tr25);
font-size: 16px;
color: var(--gray-80);
}
.profile-section__toggle:hover {
background-color: var(--gray-20);
border-color: var(--gray-40);
}
.profile-section__title {
font-weight: 600;
}
.profile-section__icon {
transition: transform var(--tr25);
font-size: 12px;
}
.profile-section__toggle[aria-expanded="true"] .profile-section__icon {
transform: rotate(180deg);
}
.profile-section__content {
transition: all var(--tr25);
overflow: hidden;
padding: 0 2px;
}
.profile-section__content--hidden {
max-height: 0;
opacity: 0;
padding: 0;
margin: 0;
}
.profile-info {
margin-bottom: 20px;
padding: 12px 16px;
background-color: var(--gray-10);
border: 1px solid var(--gray-30);
border-radius: 6px;
}
.profile-info__item {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 14px;
margin-bottom: 8px;
}
.profile-info__item:last-child {
margin-bottom: 0;
}
.profile-info__label {
color: var(--gray-60);
font-weight: 500;
}
.profile-info__value {
color: var(--gray-80);
}
.profile-subsection {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid var(--gray-20);
}
.profile-subsection__title {
margin-bottom: 20px;
color: var(--gray-80);
font-size: 18px;
font-weight: 600;
}
.auth-form__secure-note {
margin-bottom: 10px;
padding: 8px 12px;
background-color: var(--gray-10);
border: 1px solid var(--gray-30);
border-radius: 4px;
font-size: 13px;
color: var(--gray-70);
}
.auth-form__secure-icon {
margin-right: 6px;
}
.profile-fields {
display: flex;
flex-direction: column;
gap: 20px;
}
/* Стили для пользовательских свойств */
.profile-file-field {
display: flex;
flex-direction: column;
gap: 12px;
}
.profile-file-current {
padding: 8px 12px;
background-color: var(--gray-10);
border: 1px solid var(--gray-30);
border-radius: 4px;
font-size: 14px;
}
.profile-file-label {
color: var(--gray-60);
font-weight: 500;
margin-right: 8px;
}
.profile-file-link {
color: var(--primary);
text-decoration: none;
}
.profile-file-link:hover {
color: var(--green);
text-decoration: underline;
}
.profile-field-help {
margin-top: 8px;
padding: 8px 12px;
background-color: var(--gray-10);
border: 1px solid var(--gray-30);
border-radius: 4px;
font-size: 13px;
color: var(--gray-70);
font-style: italic;
}
.profile-add-field {
margin-top: 8px;
padding: 6px 12px;
font-size: 14px;
color: var(--primary);
}
.profile-add-field:hover {
color: var(--green);
}
/* Множественные checkbox'ы для enum полей */
.auth-form__field .ui-checkbox-label {
margin-bottom: 8px;
}
.auth-form__field .ui-checkbox-label:last-child {
margin-bottom: 0;
}
/* Множественные поля */
.auth-form__field input[name*="[]"]:not(:first-of-type) {
margin-top: 8px;
}
/* Textarea стили */
.auth-form__input textarea {
resize: vertical;
min-height: 80px;
}
/* JavaScript для работы с секциями */
.profile-section__content.profile-section__content--shown {
max-height: none;
opacity: 1;
}
.auth-form__errors {
margin-bottom: 20px;
}
.auth-form__error {
background-color: rgba(209, 92, 92, 0.1);
border: 1px solid var(--red);
border-radius: 6px;
padding: 12px 16px;
color: var(--red);
font-size: 14px;
margin-bottom: 8px;
}
.auth-form__error:last-child {
margin-bottom: 0;
}
.auth-form__submit {
display: flex;
gap: 20px;
}
.btn.auth-form__reset-btn,
.btn.auth-form__logout-btn {
border-radius: 6px;
}
@media (max-width: 768px) {
.profile-form .auth-form__inner {
margin: 0 20px;
padding: 30px 20px;
}
.profile-section__toggle {
padding: 10px 12px;
font-size: 15px;
}
.profile-subsection__title {
font-size: 16px;
}
.profile-file-current {
padding: 6px 10px;
}
}
@media (max-width: 480px) {
.profile-form .auth-form__inner {
margin: 0 10px;
padding: 24px 16px;
}
.profile-info__item {
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
.profile-file-current {
flex-direction: column;
gap: 6px;
}
}
Если нужен телефон из PHONE_NUMBER
result_modifier.php
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
/**
* @global object $APPLICATION
* @var array $arResult
* @var array $arParams
*/
$rawData = \Bitrix\Main\UserPhoneAuthTable::getList([
'filter' => [
'=USER_ID' => $arResult['ID']
],
'select' => [
'PHONE_NUMBER'
],
])->fetch();
$arResult['arUser']['PHONE_NUMBER'] = $rawData['PHONE_NUMBER'] ?? '';
Параметры компонента
<?$APPLICATION->IncludeComponent(
"bitrix:main.profile",
"flat",
Array(
"CHECK_RIGHTS" => "N",
"SEND_INFO" => "N",
"SET_TITLE" => "Y",
"USER_PROPERTY" => array(),
"USER_PROPERTY_NAME" => "",
"REQUIRED_FIELDS" => array("NAME", "PHONE_NUMBER"), // Добавляем
)
);?>
template.php
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
/**
* @global object $APPLICATION
* @var array $arResult
* @var array $arParams
*/
$rawData = \Bitrix\Main\UserPhoneAuthTable::getList([
'filter' => [
'=USER_ID' => $arResult['ID']
],
'select' => [
'PHONE_NUMBER'
],
])->fetch();
$arResult['arUser']['PHONE_NUMBER'] = $rawData['PHONE_NUMBER'] ?? '';
template.php
<? // Телефон: PHONE_NUMBER
$fieldRequired = in_array('PHONE_NUMBER', $arParams['REQUIRED_FIELDS'], true);
?>
<div class="auth-form__field form-field">
<label class="form-field__label auth-form__label" for="PHONE_NUMBER">
<?=GetMessage('USER_PHONE')?><? if ($fieldRequired): ?><span
class="starrequired">*</span><? endif ?>
</label>
<input
type="text"
id="PHONE_NUMBER"
name="PHONE_NUMBER"
maxlength="50"
value="<?=$arResult['arUser']['PHONE_NUMBER']?>"
class="form-control auth-form__input _mask_phone"
placeholder="+7 (000) 000-00-00"
<?=$fieldRequired ? 'required' : ''?>
/>
</div>