From 7c0012fbd97446cfa7c0e84a2d49147b0bb7b577 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Mon, 26 Feb 2018 10:16:12 -0500 Subject: [PATCH] Additional wireCount updates per processwire/processwire-issues#408 --- .../Fieldtype/FieldtypeOptions/FieldtypeOptions.module | 6 +++--- wire/modules/Fieldtype/FieldtypeURL.module | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wire/modules/Fieldtype/FieldtypeOptions/FieldtypeOptions.module b/wire/modules/Fieldtype/FieldtypeOptions/FieldtypeOptions.module index 972a8bae..12738483 100644 --- a/wire/modules/Fieldtype/FieldtypeOptions/FieldtypeOptions.module +++ b/wire/modules/Fieldtype/FieldtypeOptions/FieldtypeOptions.module @@ -106,7 +106,7 @@ class FieldtypeOptions extends FieldtypeMulti implements Module { if(empty($value) || !count($value)) { $page->set($field->name, $field->initValue); } - } else if($this->wire('process') != 'ProcessField' && !count($value)) { + } else if($this->wire('process') != 'ProcessField' && !wireCount($value)) { $this->warning( $field->getLabel() . " ($field->name): " . $this->_('Configured pre-selection not populated since value is not always required. Please correct this field configuration.') @@ -469,7 +469,7 @@ class FieldtypeOptions extends FieldtypeMulti implements Module { /** * Get all options available for the given field * - * @param id|string|Field $field Field name, id or object + * @param int|string|Field $field Field name, id or object * @return SelectableOptionArray * @throws WireException * @@ -481,7 +481,7 @@ class FieldtypeOptions extends FieldtypeMulti implements Module { /** * Update, add, delete as needed to match the given $options * - * @param id|string|Field $field Field name, id or object + * @param int|string|Field $field Field name, id or object * @param SelectableOptionArray $options Options to save * @return array Summary of what occurred * @throws WireException diff --git a/wire/modules/Fieldtype/FieldtypeURL.module b/wire/modules/Fieldtype/FieldtypeURL.module index be82ff7f..306ccff4 100644 --- a/wire/modules/Fieldtype/FieldtypeURL.module +++ b/wire/modules/Fieldtype/FieldtypeURL.module @@ -48,6 +48,7 @@ class FieldtypeURL extends FieldtypeText { public function getInputfield(Page $page, Field $field) { + /** @var InputfieldURL $inputfield */ $inputfield = $this->modules->get('InputfieldURL'); $inputfield->set('noRelative', $field->noRelative); $inputfield->set('addRoot', $field->addRoot); @@ -68,12 +69,16 @@ class FieldtypeURL extends FieldtypeText { $labelYes = $this->_('Yes'); $labelNo = $this->_('No'); + /** @var InputfieldAsmSelect $f */ $f = $inputfields->getChildByName('textformatters'); $f->notes = $this->_('The "HTML Entity Encoder" text formatter is recommended for URL fields.'); - if(!count($field->textformatters) || !in_array('TextformatterEntities', $field->textformatters)) { + $textformatters = $field->get('textformatters'); + if(!is_array($textformatters)) $textformatters = array(); + if(!count($textformatters) || !in_array('TextformatterEntities', $textformatters)) { $this->warning($this->_('If this URL will be used for any output, it is strongly recommended that you select the "HTML Entity Encoder" for "Text Formatters" on the Details tab.')); // Wwarning to use the HTML entity encoder } + /** @var InputfieldRadios $f */ $f = $this->modules->get('InputfieldRadios'); $f->attr('name', 'noRelative'); $f->label = $this->_('Allow relative/local URLs without "http://" at the beginning?');