mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 17:54:44 +02:00
Fix issue processwire/processwire-issues#901
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* For documentation about the fields used in this class, please see:
|
||||
* /wire/core/Fieldtype.php
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2020 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
*/
|
||||
@@ -56,15 +56,22 @@ class FieldtypeCheckbox extends Fieldtype {
|
||||
* @param Field $field
|
||||
* @param int|null $value
|
||||
* @param string $property
|
||||
* @return MarkupFieldtype|string
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function ___markupValue(Page $page, Field $field, $value = null, $property = '') {
|
||||
if(is_null($value)) $value = $page->get($field->name);
|
||||
$checked = $value ? " checked='checked'" : "";
|
||||
$textValue = $value ? '☒': '☐'; // utf-8 checkbox (the ☑ is also works for checked, but not quite as visible)
|
||||
if($this->wire()->page->template->name === 'admin') {
|
||||
// use fa-icon for checkbox in the admin
|
||||
$out = $checked ? wireIconMarkup('check-square-o') : wireIconMarkup('square-o');
|
||||
} else {
|
||||
// use disabled checkbox outside of the admin
|
||||
$out = "<input type='checkbox' $checked disabled='disabled' />";
|
||||
}
|
||||
// note: the span below ensures a value survives even if markupValue has tags stripped from it
|
||||
return "<input type='checkbox' $checked disabled='disabled' /><span style='display:none'>$textValue</span>";
|
||||
$textValue = $checked ? '☒' : '☐'; // utf-8 checkbox (the ☑ also works for checked, but not quite as visible)
|
||||
return $out . "<span style='display:none'>$textValue</span>";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +155,6 @@ class FieldtypeCheckbox extends Fieldtype {
|
||||
*
|
||||
*/
|
||||
public function ___getCompatibleFieldtypes(Field $field) {
|
||||
if($field) {}
|
||||
$fieldtypes = $this->wire(new Fieldtypes());
|
||||
$toggleClass = 'FieldtypeToggle';
|
||||
$allowToggle = $this->wire()->modules->isInstalled($toggleClass);
|
||||
@@ -165,4 +171,3 @@ class FieldtypeCheckbox extends Fieldtype {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user