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

Add new "Toggle" Inputfield module providing an often more useful alternative to the InputfieldCheckbox module. There is also an accompanying FieldtypeToggle, but it is still in development so probably won't be till next week's commits.

This commit is contained in:
Ryan Cramer
2019-08-30 11:34:07 -04:00
parent f5d955ef5f
commit e94e10c631
4 changed files with 677 additions and 4 deletions

View File

@@ -214,7 +214,7 @@ abstract class Inputfield extends WireData implements Module {
const skipLabelFor = true;
/**
* Don't use a label header element at all (basically, skip the label)
* Don't show a visible header (likewise, do not show the label)
* #pw-group-skipLabel-constants
*
*/
@@ -227,6 +227,14 @@ abstract class Inputfield extends WireData implements Module {
*/
const skipLabelBlank = 4;
/**
* Do not render any markup for the header/label at all
* #pw-group-skipLabel-constants
* @since 3.0.139
*
*/
const skipLabelMarkup = 8;
/**
* Plain text: no type of markdown or HTML allowed
* #pw-group-textFormat-constants

View File

@@ -583,7 +583,7 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
if(!strlen($label) && $skipLabel !== Inputfield::skipLabelBlank && $inputfield->className() != 'InputfieldWrapper') {
$label = $inputfield->attr('name');
}
if($label || $quietMode) {
if(($label || $quietMode) && $skipLabel !== Inputfield::skipLabelMarkup) {
$for = $skipLabel || $quietMode ? '' : $inputfield->attr('id');
// if $inputfield has a property of entityEncodeLabel with a value of boolean FALSE, we don't entity encode
$entityEncodeLabel = $inputfield->getSetting('entityEncodeLabel');
@@ -616,6 +616,9 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
} else if(strpos($label, '{class}') !== false) {
$label = str_replace('{class}', '', $label);
}
} else if($skipLabel === Inputfield::skipLabelMarkup) {
// no header and no markup for header
$label = '';
} else {
// no header
// $inputfield->addClass('InputfieldNoHeader', 'wrapClass');