Created
January 16, 2018 04:47
-
-
Save SergeyZaigraev/01b587064e9fbfcd4646b7c90cc37da6 to your computer and use it in GitHub Desktop.
Iblock custom property type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
class CCustomTypeElementDateText{ | |
//описываем поведение пользовательского свойства | |
function GetUserTypeDescription() { | |
return array( | |
'PROPERTY_TYPE' => 'S', | |
'USER_TYPE' => 'history', | |
'DESCRIPTION' => 'История просрочки — дата со значением', //именно это будет выведено в списке типов свойств во вкладке редактирования свойств ИБ | |
//указываем необходимые функции, используемые в создаваемом типе | |
'GetPropertyFieldHtml' => array('CCustomTypeElementDateText', 'GetPropertyFieldHtml'), | |
'ConvertToDB' => array('CCustomTypeElementDateText', 'ConvertToDB'), | |
'ConvertFromDB' => array('CCustomTypeElementDateText', 'ConvertToDB') | |
); | |
} | |
//формируем пару полей для создаваемого свойства | |
function GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName) { | |
global $APPLICATION; | |
ob_start(); | |
$APPLICATION->IncludeComponent("bitrix:main.calendar","",Array( | |
"SHOW_INPUT" => "Y", | |
"FORM_NAME" => "", | |
"INPUT_NAME" => $strHTMLControlName["VALUE"], | |
"INPUT_NAME_FINISH" => "", | |
"INPUT_VALUE" => $value["VALUE"], | |
"INPUT_VALUE_FINISH" => "", | |
"SHOW_TIME" => "N", | |
"HIDE_TIMEBAR" => "Y" | |
) | |
); | |
$date_input = ob_get_contents(); | |
ob_end_clean(); | |
$html = $date_input; | |
$html .= '<input type="text" name="'.$strHTMLControlName["DESCRIPTION"].'" value="'.$value["DESCRIPTION"].'">'; | |
$html .= '</br>'; | |
return $html; | |
} | |
//сохраняем в базу | |
function ConvertToDB($arProperty, $value){ | |
return $value; | |
} | |
//читаем из базы | |
function ConvertFromDB($arProperty, $value){ | |
return $value; | |
} | |
} | |
AddEventHandler('iblock', 'OnIBlockPropertyBuildList', array('CCustomTypeElementDateText', 'GetUserTypeDescription')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment