mirror of
https://github.com/processwire/processwire.git
synced 2025-08-21 05:51:41 +02:00
Update FieldtypeOptions to support InputfieldTextTags as an input module
This commit is contained in:
@@ -179,6 +179,12 @@ class FieldtypeOptions extends FieldtypeMulti implements Module {
|
|||||||
// assumed to be an option ID
|
// assumed to be an option ID
|
||||||
$value = $this->manager->getOptionsByID($field, array((int) $value));
|
$value = $this->manager->getOptionsByID($field, array((int) $value));
|
||||||
|
|
||||||
|
} else if(is_string($value) && $field->get('inputfieldClass') === 'InputfieldTextTags') {
|
||||||
|
/** @var InputfieldTextTags $inputfield */
|
||||||
|
$inputfield = $this->wire()->modules->getModule('InputfieldTextTags', array('noInit' => true));
|
||||||
|
$value = $inputfield->tagStringToArray($value);
|
||||||
|
$value = $this->manager->getOptions($field, array('id' => $value));
|
||||||
|
|
||||||
} else if(is_string($value)) {
|
} else if(is_string($value)) {
|
||||||
// may be option 'title' (first) or option 'value' (second)
|
// may be option 'title' (first) or option 'value' (second)
|
||||||
$_value = $value; // save for second check
|
$_value = $value; // save for second check
|
||||||
|
@@ -156,6 +156,7 @@ class SelectableOptionConfig extends Wire {
|
|||||||
|
|
||||||
$labelSingle = $this->_('Single value');
|
$labelSingle = $this->_('Single value');
|
||||||
$labelMulti = $this->_('Multiple values');
|
$labelMulti = $this->_('Multiple values');
|
||||||
|
$labelSortable = $this->_('Multiple sortable values');
|
||||||
|
|
||||||
$f = $modules->get('InputfieldSelect');
|
$f = $modules->get('InputfieldSelect');
|
||||||
$f->attr('name', 'inputfieldClass');
|
$f->attr('name', 'inputfieldClass');
|
||||||
@@ -167,9 +168,11 @@ class SelectableOptionConfig extends Wire {
|
|||||||
if($module instanceof ModulePlaceholder) {
|
if($module instanceof ModulePlaceholder) {
|
||||||
$module = $modules->getModule($module->className(), array('noInit' => true));
|
$module = $modules->getModule($module->className(), array('noInit' => true));
|
||||||
}
|
}
|
||||||
if($module instanceof InputfieldSelect) {
|
if($module instanceof InputfieldSelect || $module instanceof InputfieldHasSelectableOptions) {
|
||||||
$name = str_replace('Inputfield', '', $module->className());
|
$name = str_replace('Inputfield', '', $module->className());
|
||||||
if($module instanceof InputfieldSelectMultiple) {
|
if($module instanceof InputfieldHasSortableValue) {
|
||||||
|
$name .= " ($labelSortable)";
|
||||||
|
} else if($module instanceof InputfieldSelectMultiple) {
|
||||||
$name .= " ($labelMulti)";
|
$name .= " ($labelMulti)";
|
||||||
} else {
|
} else {
|
||||||
$name .= " ($labelSingle)";
|
$name .= " ($labelSingle)";
|
||||||
@@ -210,7 +213,9 @@ class SelectableOptionConfig extends Wire {
|
|||||||
foreach($options as $option) {
|
foreach($options as $option) {
|
||||||
$f->addOption($option->id, $option->title);
|
$f->addOption($option->id, $option->title);
|
||||||
}
|
}
|
||||||
$f->attr('value', $field->get('initValue'));
|
$initValue = $field->get('initValue');
|
||||||
|
if($f instanceof InputfieldHasArrayValue && !is_array($initValue) && !empty($initValue)) $initValue = explode(' ', $initValue);
|
||||||
|
$f->attr('value', $initValue);
|
||||||
if(!$field->required && !$field->requiredIf) {
|
if(!$field->required && !$field->requiredIf) {
|
||||||
$f->notes = $this->_('Please note: your selections here do not become active unless a value is *always* required for this field. See the "required" option on the Input tab of your field settings.');
|
$f->notes = $this->_('Please note: your selections here do not become active unless a value is *always* required for this field. See the "required" option on the Input tab of your field settings.');
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user