diff --git a/wire/core/Inputfield.php b/wire/core/Inputfield.php index 351b7e47..600172e2 100644 --- a/wire/core/Inputfield.php +++ b/wire/core/Inputfield.php @@ -3,7 +3,7 @@ /** * ProcessWire Inputfield - base class for Inputfield modules. * - * ProcessWire 3.x, Copyright 2016 by Ryan Cramer + * ProcessWire 3.x, Copyright 2021 by Ryan Cramer * https://processwire.com * * An Inputfield for an actual form input field widget, and this is provided as the base class @@ -101,6 +101,7 @@ * @property null|bool|Fieldtype $hasFieldtype The Fieldtype using this Inputfield, or boolean false when known not to have a Fieldtype, or null when not known. #pw-group-other * @property null|Field $hasField The Field object associated with this Inputfield, or null when not applicable or not known. #pw-group-other * @property null|Page $hasPage The Page object associated with this Inputfield, or null when not applicable or not known. #pw-group-other + * @property null|Inputfield $hasInputfield If this Inputfield is owned/managed by another (other than parent/child relationship), it may be set here. 3.0.176+ #pw-group-other * @property bool|null $useLanguages When multi-language support active, can be set to true to make it provide inputs for each language, where supported (default=false). #pw-group-behavior * @property null|bool|int $entityEncodeLabel Set to boolean false to specifically disable entity encoding of field header/label (default=true). #pw-group-output * @property null|bool $entityEncodeText Set to boolean false to specifically disable entity encoding for other text: description, notes, etc. (default=true). #pw-group-output diff --git a/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module b/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module index a6d29018..2d8c4c79 100644 --- a/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module +++ b/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module @@ -509,6 +509,9 @@ class InputfieldPage extends Inputfield implements ConfigurableModule { $inputfield = $this->wire()->modules->get($this->getInputfieldClass()); if(!$inputfield) return null; + $inputfield->set('hasField', $this->hasField); + $inputfield->set('hasInputfield', $this); + $page = $this->page; $input = $this->wire()->input; $process = $this->wire()->process; @@ -721,7 +724,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule { if(!$inputfield) return ''; $key = "_{$this->name}_add_items"; - if($inputfield instanceof InputfieldHasArrayValue) { + if($inputfield instanceof InputfieldHasArrayValue || $inputfield instanceof InputfieldSupportsArrayValue) { // multi value $description = $this->_('Enter the titles of the items you want to add, one per line. They will be created and added to your selection when you save the page.'); $input = ""; @@ -732,7 +735,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule { } $notes = sprintf($this->_('New pages will be added to %s'), $parent->path); - $label =" " . $this->_('Create New'); + $label = wireIconMarkup('plus-circle', 'fw') . $this->_('Create New'); $out = "
" . sprintf($this->_('URL handler example in %s for URL: %s'), '/site/init.php', "$exampleUrl") . '
' . + "" .
+ '$wire->addHook("/find-tags/", function($e) { ' .
+ "\n " . '$q = $e->input->get("q", "text,selectorValue");' .
+ "\n " . 'if(strlen($q) < 3) return [];' .
+ "\n " . 'return $e->pages->find("parent=/categories/, title%=$q")->explode("title");' .
+ "\n});" .
+ "
" .
+ "" . $this->_('This example finds titles from pages to use as tags, but you may use whatever data source you want.') . "
"; + $f->val($this->tagsUrl); + $f->collapsed = Inputfield::collapsedBlank; + $fieldset->add($f); + } else { + /** @var InputfieldHidden $f */ + $f = $modules->get('InputfieldHidden'); + $f->attr('name', 'tagsUrl'); + $f->val(''); + $fieldset->add($f); } - /** @var InputfieldTextarea $f */ - $f = $modules->get('InputfieldTextarea'); - $f->attr('name', 'tagsList'); - $f->label = $this->label = $this->_('Predefined tags'); - $f->description = $this->_('Enter predefined tags, 1 per line. To define separate tag and label, specify `tag=label` on the line.'); - $f->notes = $this->_('Tags may not contain the delimiter selected below but labels can.'); - $f->val($this->tagsListArrayToString($this->tagsList)); - if($languages) { - $f->description .= ' ' . $this->_('To define separate labels per-language, re-enter each tag (with label) for each language.'); - $f->useLanguages = true; - foreach($languages as $language) { - if(!$language->isDefault()) $f->set("value$language", $this->tagsListArrayToString($this->get("tagsList$language"))); - } + if($isTextField) { + /** @var InputfieldToggle $f */ + $f = $modules->get('InputfieldToggle'); + $f->attr('name', 'allowUserTags'); + $f->label = $this->_('Allow user to enter their own tags?'); + $f->val($this->allowUserTags); + $fieldset->add($f); + } else { + /** @var InputfieldHidden $f */ + $f = $modules->get('InputfieldHidden'); + $f->attr('name', 'allowUserTags'); + $f->val('0'); + $fieldset->add($f); } - $fieldset->add($f); - - /** @var InputfieldToggle $f */ - $f = $modules->get('InputfieldToggle'); - $f->attr('name', 'allowUserTags'); - $f->label = $this->_('Allow user to enter their own tags?'); - $f->val($this->allowUserTags); - $f->columnWidth = 33; - $fieldset->add($f); - + /** @var InputfieldToggle $f */ $f = $modules->get('InputfieldToggle'); $f->attr('name', 'closeAfterSelect'); - $f->label = $this->_('Close dropdown after each selection is made'); - $f->columnWidth = 34; + $f->label = $this->_('Close dropdown after each selection is made?'); $f->val($this->closeAfterSelect); $fieldset->add($f); - /** @var InputfieldRadios $f */ - $f = $modules->get('InputfieldRadios'); - $f->attr('name', 'delimiter'); - $f->label = $this->_('Tag delimiter'); - $f->addOption('s', $this->_('Space')); - $f->addOption('c', $this->_('Comma')); - $f->addOption('p', $this->_('Pipe')); - $f->optionColumns = 1; - $f->columnWidth = 33; - $f->val($this->delimiter(true)); - $fieldset->add($f); + if($isTextField) { + /** @var InputfieldRadios $f */ + $f = $modules->get('InputfieldRadios'); + $f->attr('name', 'delimiter'); + $f->label = $this->_('Tag delimiter'); + $f->addOption('s', $this->_('Space')); + $f->addOption('c', $this->_('Comma')); + $f->addOption('p', $this->_('Pipe')); + $f->optionColumns = 1; + $f->val($this->delimiter(true)); + $fieldset->add($f); + } return $inputfields; } diff --git a/wire/modules/Inputfield/InputfieldTextTags/InputfieldTextTags.scss b/wire/modules/Inputfield/InputfieldTextTags/InputfieldTextTags.scss index 4204ad65..7b401537 100644 --- a/wire/modules/Inputfield/InputfieldTextTags/InputfieldTextTags.scss +++ b/wire/modules/Inputfield/InputfieldTextTags/InputfieldTextTags.scss @@ -10,6 +10,9 @@ $tag-border-colors: #b1c3d4 #cbd7e3 #cbd7e3 #cbd7e3; input.InputfieldTextTagsInput:not(.selectized) { color: $tag-background-color; } + .InputfieldPageAdd { + display: none; // handled internally + } } .Inputfield {