thei Posted September 26, 2024 Posted September 26, 2024 i'm using Rockmigrations the first time. I copied field settings (Rockmigration Code) from an Processwire site in the migration.php of a new Processwire environment. It works fine except for one options field: it throws Fatal error: Uncaught Error: Class "ProcessWire\SelectableOptionManager" not found in /var/www/html/app/site/modules/RockMigrations/RockMigrations.module.php on line 4144 here is the code $rm->createField('country', 'text', [ 'collapsed' => 0, 'columnWidth' => 100, 'defaultValue' => '', 'flags' => 0, 'icon' => 'flag-o', 'initValue' => '', 'inputfieldClass' => 'InputfieldSelect', 'label' => 'Country', 'options' => [ 65 => 'Germany', 120 => 'Namibia', 1 => 'Afghanistan', 2 => 'Albania', 3 => 'Algeria', 4 => 'Andorra', 5 => 'Angola', 6 => 'Antigua and Barbuda', 7 => 'Argentina', 8 => 'Armenia', 9 => 'Australia', 10 => 'Austria', ...etc... ], 'required' => '', 'requiredIf' => '', 'showIf' => '', 'tags' => 'address', 'themeBorder' => '', 'themeColor' => '', 'themeInputSize' => '', 'themeInputWidth' => '', 'themeOffset' => '', 'type' => 'FieldtypeOptions', ]); I do not understand what the problem is with the options field Thanx for ideas and help 🐵
bernhard Posted September 26, 2024 Posted September 26, 2024 This is my snippet that I'm using: // Add a options field via RockMigrations 'your_field_name' => [ 'type' => 'options', 'label' => 'Your Field Label', 'icon' => 'cubes', 'options' => [ 1 => 'ONE|This is option one', 2 => 'TWO', 3 => 'THREE', ], ], You get those snippets when using VSCode + enabling them from the module settings: Does the snippet's code work for you?
thei Posted September 26, 2024 Author Posted September 26, 2024 Thank you! This way - using 'migrate' instead of 'createField' - it works.
bernhard Posted September 26, 2024 Posted September 26, 2024 You can also use createField, just make sure to use the same settings that I provided. The "field code" in the backend is not 100% accurate all the time. 47 minutes ago, thei said: $rm->createField('country', 'text', [ Most importantly you need to change this from "text" to "options".
thei Posted September 26, 2024 Author Posted September 26, 2024 (edited) Ah! i see. It's the keyword 'options'. In my example i used 'text'. I just tested it and it works using when 'createField()' - great! Thank you!! Edited September 26, 2024 by thei 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now