36 $value = current($value);
48 return mb_strtoupper($value) !=
'N' && !empty($value)
62 $type = $toTypeClass::getType();
67 $value = (int)($value ==
'Y');
72 if (in_array(mb_strtolower($value), [
'y',
'yes',
'true',
'1'],
true))
76 elseif (in_array(mb_strtolower($value), [
'n',
'no',
'false',
'0'],
true))
81 $value = $value ==
'Y' ?
'Y' :
'N';
118 $className = $isPublicControl ? static::generateControlClassName($fieldType, $field) :
'';
120 $renderResult = sprintf(
121 '<select id="%s" name="%s" class="%s">',
122 htmlspecialcharsbx(static::generateControlId($field)),
123 htmlspecialcharsbx(static::generateControlName($field)),
124 htmlspecialcharsbx($className)
129 $renderResult .=
'<option value="">['.Loc::getMessage(
"BPDT_BOOL_NOT_SET").
']</option>';
132 $renderResult .= sprintf(
133 '<option value="Y"%s>%s</option>
134 <option value="N"%s>%s</option>
136 $value ===
'Y' ?
' selected' :
'',
138 $value ===
'N' ?
' selected' :
'',
142 return $renderResult;
149 $allowSelection =
false;
152 return parent::renderControlSingle($fieldType, $field, $value, $allowSelection, $renderMode);
159 $allowSelection =
false;
162 return parent::renderControlMultiple($fieldType, $field, $value, $allowSelection, $renderMode);
182 $value = parent::extractValue($fieldType, $field, $request);
184 if ($value !==
null && $value !==
'Y' && $value !==
'N')
188 $value = $value ?
'Y' :
'N';
190 elseif (is_string($value) && $value <>
'')
192 $value = mb_strtolower($value);
193 if (in_array($value, array(
'y',
'yes',
'true',
'1')))
197 elseif (in_array($value, array(
'n',
'no',
'false',
'0')))
204 static::addError(array(
205 'code' =>
'ErrorValue',
207 'parameter' => static::generateControlName($field),
222 $map = $fieldType->
getSettings()[
'ExternalValues'] ??
null;
223 if ($map && isset($map[$value]))
228 return parent::externalizeValue($fieldType, $context, $value);
233 $valueA = \CBPHelper::getBool($valueA);
234 $valueB = \CBPHelper::getBool($valueB);
236 return parent::compareValues($valueA, $valueB);
static convertTo(FieldType $fieldType, $value, $toTypeClass)
static renderControl(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
static extractValue(FieldType $fieldType, array $field, array $request)
static externalizeValue(FieldType $fieldType, $context, $value)
static renderControlSingle(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
static formatValuePrintable(FieldType $fieldType, $value)
static toSingleValue(FieldType $fieldType, $value)
static renderControlMultiple(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
static getConversionMap()
static compareValues($valueA, $valueB)
static canRenderControl($renderMode)
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)