Jump to content

Migration of Options Field fails Class "ProcessWire\SelectableOptionManager" not found ...RockMigrations.module.php on line 4144


thei
 Share

Recommended Posts

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

🐵

Link to comment
Share on other sites

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:

snippets.gif?t=1727308382

Does the snippet's code work for you?

Link to comment
Share on other sites

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".

Link to comment
Share on other sites

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 by thei
  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...