trk / mystique Goto Github PK
View Code? Open in Web Editor NEWMystique is a config file based field creation module for ProcessWire CMS/CMF by ALTI VE BIR IT.
Mystique is a config file based field creation module for ProcessWire CMS/CMF by ALTI VE BIR IT.
The process of finding all Mystique config files takes very long.
This part of the code alone takes about 200-300ms (which doubles loading times) in my setup with 6 Modules (Mystique excluded):
Lines 118 to 124 in c15a95a
I have encountered this issue while developing a module with a node_modules folder in it. With this node_modules inside my module, a page load took about 15 seconds, which is definitely too much. But there is no option to disable searching inside of this large folder.
Maybe it would be a good idea to give developers the possibility to further restrict the directories in which should be searched with the excludeDirNames
option for Wire->files->find
(Documentation).
Another option would be to register all config files by hand, or registering just individual directories. Something like this:
// Inside another module
$wire->modules->get('Mystique')->registerConfigPath('path/to/config/files/');
I noticed that with the new Mystique-next version, it saves the user inputted field data as well as the resource info. Is it necessary to save the resource info in the database as well? Why not just have it reference the PHP file?
Good day @trk !
I am using Mystique fields inside my Repeater and Repeater Matrix items. Those items are indeed pages under Admin/Repeaters
in the pages tree. If I go there in admin interface and try to edit these pages, I get an error (see the screenshot below):
If I remove the Mystique field from the RM template, everything works like it should. Could you please look into this?
I have a custom field like this:
'test' => [
'label' => __('Test'),
'type' => Mystique::SELECT,
'options' => [
'10' => 'A',
'20' => 'B',
'30' => 'C',
],
'required' => false,
'columnWidth' => 100,
],
When I view that on my page, the values get shifted for some reason. If you inspect the select dropdown, the values will be like this:
<option value="0">A</option>
<option value="1">B</option>
<option value="2">C</option>
It should be this:
<option value="10">A</option>
<option value="20">B</option>
<option value="30">C</option>
It seems as though if the values in a select are integers (whether actual integers or strings that are integers), Mystique has problems rendering the values correctly.
I'm using PHP 8.1 and ProcessWire 3.0.201.
Great module! Makes a lot of work easier and avoids unnecessary fields. Thanks! It would be very useful if support for "required" and "requiredIf" existed. Do you think it is possible to implement this?
See video:
https://youtu.be/CJR_8yJ_2mo
I upgraded to the latest Mystique-next version. When creating a new field, I get the following error.
Fatal Error: Uncaught ArgumentCountError: Too few arguments to function Altivebir\Mystique\MystiqueValue::__construct(), 0 passed in site/modules/Mystique/FieldtypeMystique.module.php on line 244 and at least 1 expected in site/modules/Mystique/src/MystiqueValue.php:26
#0 site/modules/Mystique/FieldtypeMystique.module.php(244): Altivebir\Mystique\MystiqueValue->__construct()
#1 wire/modules/Page/PageFrontEdit/PageFrontEditConfig.php (148): FieldtypeMystique->getBlankValue(Object(NullPage), Object(Field))
#2 wire/modules/Process/ProcessField/ProcessField.module (1430): PageFrontEditConfig->fieldHelpInputfields(Object(InputfieldFieldset), Object(Field))
#3 wire/modules/Process/ProcessField/ProcessField.module (1392): ProcessField->buildEditFormFrontEdit(Object(Inp (line 26 of site/modules/Mystique/src/MystiqueValue.php)
This error message was shown because: you are logged in as a Superuser. Error has been logged.
Hi @trk . Thank you for your effort.
JS, CSS assets of the fields that are present inside Mystique that is inside ajax-loaded Repeater/Matrix field are not being preloaded.
InputfieldRepeater has a method that preloads assets, but probably because subfields of Mystique field are managed with custom FormManger and are not 'native' fields this method can't handle their assets.
Example of the InputfieldToggle without loaded assets:
As a solution, we can have some method inside FormManager that will return an array of all inputfield types and then we can loop through them calling modules()->loadModuleFileAssets('InputfieldName');
Currently, Mystique-next cannot find my Mystique config files in my custom module located here:
/site/modules/MyModule/foo/bar/configs/Mystique.mytestfield.php
Possible to fix?
This Module is initializing in the ready
Method of Processwire, which is called when the current page is ready to render.
See here:
Line 93 in c677403
This leads to the issue, that other modules that are trying to access Mystique Fields in their init
method are getting null
for every requested field instead of the actual value. I've tried to replace ready
with init
, and everything works as expected. So, is there a reason that you are usingready
, or could you maybe change this, so that other modules can access Mystique Fields in their init
method?
PS: Great module, saves a lot of work setting up unneccesary fields!
I have an issue that is occurring only on one particular installation of ProcessWire. I can't replicate this issue on another installation. I've tried deleting all my Mystique fields, reinstalling the module, disabling other modules, removing hooks, and a bunch of other things, but I really can't figure out why I'm getting this error only on this installation.
When I create a new field (using Mystique) and hit save, I get this error:
Error "ProcessField: You need to select a resource and save field before start to use Mystique."
This error occurs also when trying to edit any other field once I've created that buggy field, whether it's Mystique or not.
Now, if I edit my database manually (using phpmyadmin) and assign the resource, it will work.
To delete the field, I have to temporarily edit /src/MystiqueValue.php and disable line 93. The error goes away allowing me to remove the field so my site doesn't break.
Any ideas what this could be and if possible, is there some sort of fix that can be implemented?
Debug backtrace:
DEBUG MODE BACKTRACE ($config->debug == true):
#0 /alef-dev/site/modules/Mystique/FieldtypeMystique.module.php(73): Altivebir\Mystique\MystiqueValue->__construct(Object(ProcessWire\NullPage), Object(ProcessWire\Field))
#1 /processwire-dev/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module(1054): ProcessWire\FieldtypeMystique->getBlankValue(Object(ProcessWire\NullPage), Object(ProcessWire\Field))
#2 /processwire-dev/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module(943): ProcessWire\InputfieldSelector->renderSelectFieldOption(Object(ProcessWire\Field), Array, '')
#3 /processwire-dev/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module(1923): ProcessWire\InputfieldSelector->renderSelectField(Array)
#4 /processwire-dev/wire/core/Wire.php(394): ProcessWire\InputfieldSelector->___render()
#5 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___render', Array)
#6 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\InputfieldSelector), 'render', Array)
#7 /processwire-dev/wire/core/InputfieldWrapper.php(912): ProcessWire\Wire->__call('render', Array)
#8 /processwire-dev/wire/core/Wire.php(400): ProcessWire\InputfieldWrapper->___renderInputfield(Object(ProcessWire\InputfieldSelector), false)
#9 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___renderInputf...', Array)
#10 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\InputfieldFieldset), 'renderInputfiel...', Array)
#11 /processwire-dev/wire/core/InputfieldWrapper.php(592): ProcessWire\Wire->__call('renderInputfiel...', Array)
#12 /processwire-dev/wire/modules/Inputfield/InputfieldFieldset.module(18): ProcessWire\InputfieldWrapper->___render()
#13 /processwire-dev/wire/core/Wire.php(394): ProcessWire\InputfieldFieldset->___render()
#14 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___render', Array)
#15 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\InputfieldFieldset), 'render', Array)
#16 /processwire-dev/wire/core/InputfieldWrapper.php(912): ProcessWire\Wire->__call('render', Array)
#17 /processwire-dev/wire/core/Wire.php(400): ProcessWire\InputfieldWrapper->___renderInputfield(Object(ProcessWire\InputfieldFieldset), false)
#18 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___renderInputf...', Array)
#19 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\InputfieldWrapper), 'renderInputfiel...', Array)
#20 /processwire-dev/wire/core/InputfieldWrapper.php(592): ProcessWire\Wire->__call('renderInputfiel...', Array)
#21 /processwire-dev/wire/core/Wire.php(394): ProcessWire\InputfieldWrapper->___render()
#22 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___render', Array)
#23 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\InputfieldWrapper), 'render', Array)
#24 /processwire-dev/wire/core/InputfieldWrapper.php(912): ProcessWire\Wire->__call('render', Array)
#25 /processwire-dev/wire/core/Wire.php(400): ProcessWire\InputfieldWrapper->___renderInputfield(Object(ProcessWire\InputfieldWrapper), false)
#26 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___renderInputf...', Array)
#27 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\InputfieldForm), 'renderInputfiel...', Array)
#28 /processwire-dev/wire/core/InputfieldWrapper.php(592): ProcessWire\Wire->__call('renderInputfiel...', Array)
#29 /processwire-dev/wire/modules/Inputfield/InputfieldForm.module(144): ProcessWire\InputfieldWrapper->___render()
#30 /processwire-dev/wire/core/Wire.php(394): ProcessWire\InputfieldForm->___render()
#31 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___render', Array)
#32 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\InputfieldForm), 'render', Array)
#33 /processwire-dev/wire/modules/Process/ProcessField/ProcessField.module(783): ProcessWire\Wire->__call('render', Array)
#34 /processwire-dev/wire/core/Wire.php(394): ProcessWire\ProcessField->___executeEdit()
#35 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___executeEdit', Array)
#36 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessField), 'executeEdit', Array)
#37 /processwire-dev/wire/core/ProcessController.php(337): ProcessWire\Wire->__call('executeEdit', Array)
#38 /processwire-dev/wire/core/Wire.php(394): ProcessWire\ProcessController->___execute()
#39 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___execute', Array)
#40 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessController), 'execute', Array)
#41 /processwire-dev/wire/core/admin.php(160): ProcessWire\Wire->__call('execute', Array)
#42 /processwire-dev/wire/modules/AdminTheme/AdminThemeUikit/controller.php(15): require('/p...')
#43 /alef-dev/site/templates/admin.php(381): require('/p...')
#44 /processwire-dev/wire/core/TemplateFile.php(318): require('/a...')
#45 /processwire-dev/wire/core/Wire.php(394): ProcessWire\TemplateFile->___render()
#46 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___render', Array)
#47 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array)
#48 /processwire-dev/wire/modules/PageRender.module(536): ProcessWire\Wire->__call('render', Array)
#49 /processwire-dev/wire/core/Wire.php(397): ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent))
#50 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___renderPage', Array)
#51 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageRender), 'renderPage', Array)
#52 /processwire-dev/wire/core/WireHooks.php(924): ProcessWire\Wire->__call('renderPage', Array)
#53 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\DefaultPage), 'render', Array)
#54 /processwire-dev/wire/modules/Process/ProcessPageView.module(221): ProcessWire\Wire->__call('render', Array)
#55 /processwire-dev/wire/core/Wire.php(397): ProcessWire\ProcessPageView->___execute(true)
#56 /processwire-dev/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___execute', Array)
#57 /processwire-dev/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessPageView), 'execute', Array)
#58 /alef-dev/index.php(55): ProcessWire\Wire->__call('execute', Array)
#59 {main}
Tested on PW 3.0.170 and latest version of Mystique.
Can you please support wrapAttr?
In the master version, it would look like this in MystiqueFormManager.php:
foreach ($field as $property => $value) {
if($property != 'value') {
if(is_array($value) && $property == 'showIf') {
$inputField->{$property} = $this->buildShowIF($value);
} else if(is_array($value) && $property == 'set' && count($value)) {
foreach ($value as $prop => $val) {
$inputField->set($prop, $val);
}
// start new code
} else if($property == "wrapAttr" && count($value) ) {
foreach ($value as $prop => $val) {
$inputField->wrapAttr($prop, $val);
}
// end new code
} else {
$inputField->{$property} = $value;
}
}
}
On pages without template context, such as the user templates, Mystique causes a fatal error. Here is a quick workaround. Maybe you have a better solution for the problem?
2020-05-18 14:50:26 admin http://localhost/testing/pw-fzmcms-xdebug/fzmcms/access/users/
Fatal Error: Uncaught Error: Call to a member function getField() on null in C:\xampp\htdocs\testing\pw-fzmcms-xdebug\site\modules\Mystique\FieldtypeMystique.module.php:71
Stack trace:
#0 C:\xampp\htdocs\testing\pw-fzmcms-xdebug\wire\modules\Inputfield\InputfieldSelector\InputfieldSelector.module(1052): ProcessWire\FieldtypeMystique->getBlankValue(Object(ProcessWire\NullPage), Object(ProcessWire\Field))
#1 C:\xampp\htdocs\testing\pw-fzmcms-xdebug\wire\modules\Inputfield\InputfieldSelector\InputfieldSelector.module(941): ProcessWire\InputfieldSelector->renderSelectFieldOption(Object(ProcessWire\Field), Array, 'name')
#2 C:\xampp\htdocs\testing\pw-fzmcms-xdebug\wire\modules\Inputfield\InputfieldSelector\InputfieldSelector.module(1958): ProcessWire\InputfieldSelector->renderSelectField(Array, 'name')
#3 C:\xampp\htdocs\testing\pw-fzmcms-xdebug\wire\core\Wire.php(380): ProcessWire\InputfieldSelector->___render()
#4 C:\xampp\htdocs\testing\pw-fzmcms-xdebug\wire\core\WireHooks.php(823): ProcessWire\Wire->_callMethod('___render' (line 71 of C:\xampp\htdocs\testing\pw-fzmcms-xdebug\site\modules\Mystique\FieldtypeMystique.module.php)
Change line 71 in the file FieldtypeMytique.module.php from:
return new MystiqueValue($page, $page->template->fieldgroup->getField($field,true));
to the following:
return ($page instanceof NullPage) ? new MystiqueValue($page, $field) : new MystiqueValue($page, $page->template->fieldgroup->getField($field, true));
Good day, @trk !
Every time I come back to your superb module, I am on a crossroads - which version should I use: master or next. They've been split for quite some time now. So my questions are:
Thanks!
Since the update to PW 3.0.164 (Master or DEV) the rendering of mystique fields is no longer correct. The attribute "columnWidth" in the configuration shows no effect if the value is less than 100. For example:
The theme is not important here. In all themes (Default Theme, Reno Theme, UIKit Theme or Boss Theme), this rendering bug is present.
I also use the latest Mystique version 0.0.15
What I already noticed is that if you look in the browser developer console source code the data attribute colwidth="50%"
is set correctly, but compared to regular fields the style attribute style="width: 50%"
is not set.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.