mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 10:15:28 +02:00
Update for processwire/processwire-issues#1467
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Code by Ryan Cramer
|
||||
* Sponsored by Avoine
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
*/
|
||||
@@ -20,22 +20,19 @@ class FieldtypeSelector extends Fieldtype {
|
||||
'version' => 13,
|
||||
'summary' => 'Build a page finding selector visually.',
|
||||
'author' => 'Avoine + ProcessWire',
|
||||
);
|
||||
}
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
);
|
||||
}
|
||||
|
||||
public function getInputfield(Page $page, Field $field) {
|
||||
$inputfield = $this->wire('modules')->get('InputfieldSelector');
|
||||
/** @var InputfieldSelector $inputfield */
|
||||
$inputfield = $this->wire()->modules->get('InputfieldSelector');
|
||||
$inputfield->initValue = $field->get('initValue');
|
||||
return $inputfield;
|
||||
}
|
||||
|
||||
public function ___getCompatibleFieldtypes(Field $field) {
|
||||
$fieldtypes = $this->wire(new Fieldtypes());
|
||||
foreach($this->wire('fieldtypes') as $fieldtype) {
|
||||
foreach($this->wire()->fieldtypes as $fieldtype) {
|
||||
if($fieldtype instanceof FieldtypeText || $fieldtype instanceof FieldtypeSelector) {
|
||||
$fieldtypes->add($fieldtype);
|
||||
}
|
||||
@@ -52,15 +49,16 @@ class FieldtypeSelector extends Fieldtype {
|
||||
}
|
||||
|
||||
public function ___sleepValue(Page $page, Field $field, $value) {
|
||||
$initValue = trim($field->get('initValue'));
|
||||
$initValue = trim((string) $field->get('initValue'));
|
||||
$value = (string) $value;
|
||||
if(strlen($initValue) && strpos($value, $initValue) === 0) {
|
||||
$value = trim(substr($value, strlen($initValue)+1), ', ');
|
||||
$value = trim((string) substr($value, strlen($initValue)+1), ', ');
|
||||
}
|
||||
return parent::___sleepValue($page, $field, $value);
|
||||
}
|
||||
|
||||
public function ___wakeupValue(Page $page, Field $field, $value) {
|
||||
$value = parent::___wakeupValue($page, $field, $value);
|
||||
$value = (string) parent::___wakeupValue($page, $field, $value);
|
||||
$initValue = trim((string) $field->get('initValue'));
|
||||
if(strlen($initValue) && strpos($value, $initValue) === false) {
|
||||
$value = "$initValue, $value";
|
||||
@@ -77,7 +75,7 @@ class FieldtypeSelector extends Fieldtype {
|
||||
*/
|
||||
public function getDatabaseSchema(Field $field) {
|
||||
$schema = parent::getDatabaseSchema($field);
|
||||
$len = $this->wire('database')->getMaxIndexLength();
|
||||
$len = $this->wire()->database->getMaxIndexLength();
|
||||
$schema['data'] = 'text NOT NULL';
|
||||
$schema['keys']['data_exact'] = "KEY `data_exact` (`data`($len))";
|
||||
$schema['keys']['data'] = 'FULLTEXT KEY `data` (`data`)';
|
||||
|
Reference in New Issue
Block a user