1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 02:04:35 +02:00

Fix issue processwire/processwire-issues#686 where FieldtypeCheckbox::markupValue() result ended up blank after a PHP strip_tags()

This commit is contained in:
Ryan Cramer
2018-09-13 10:07:29 -04:00
parent 272077b1cf
commit 2c9b25fdfd

View File

@@ -35,10 +35,13 @@ class FieldtypeCheckbox extends Fieldtype {
public function ___markupValue(Page $page, Field $field, $value = null, $property = '') {
if(is_null($value)) $value = $page->get($field->name);
$checked = $value ? " checked='checked'" : "";
return "<input type='checkbox'$checked disabled='disabled' />";
$textValue = $value ? '☒': '☐'; // utf-8 checkbox (the ☑ is also works for checked, but not quite as visible)
// 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>";
}
public function getInputfield(Page $page, Field $field) {
/** @var InputfieldCheckbox $inputfield */
$inputfield = $this->modules->get('InputfieldCheckbox');
$inputfield->set('checkedValue', 1);
$inputfield->set('uncheckedValue', 0);