Jump to content

Creating columns in database with FieldtypeCombo


Clarity
 Share

Recommended Posts

Hello!

I would like to report an issue I noticed.

I migrated a FieldtypeCombo field using the RockMigrations module. The field was transferred with the warning: FieldtypeCombo: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_global_settings_combo.i3' in 'field list'.

To figure out this error, I exported this FieldtypeCombo field and compared the database state in both cases.

After a normal export, the database looks like this:

image.png.064cd52e89b35d5badea0a9310475ff4.png


After migrating using RockMigrations, the database looks like this:

image.png.c09600d15310b4224040678368bfb8b7.png


As you can see, the database is missing columns "i3", "i4", "i5", "i6".

Can you please tell me how it is possible to create them?

Link to comment
Share on other sites

  • Clarity changed the title to Creating columns in database with FieldtypeCombo

@Clarity, Combo is a 1st party Pro field and it seems to be not supported out of the box with Rock Migrations. I think that only Repeater Matrix field is supported of all Ryan's Pro fields thanks to @gebeer's work. Those Pro fields all need special treatment and you can't expect them to work with just createField().

But you can always fall back to just raw ProcessWire api and create the Combo field with just that. See here how to do it if you got Pro fields support board access. If you don't, here is the code Ryan suggested (hope this is alright to post it here):

image.thumb.png.a27f4dfbfd995d0fc12b3d6f3bafb778.png

You can make a special method for Rock Migrations out of this (should be pretty easy if this code works) and make a PR if you want it there))

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

22 hours ago, Ivan Gretsky said:

@Clarity, Combo is a 1st party Pro field and it seems to be not supported out of the box with Rock Migrations. I think that only Repeater Matrix field is supported of all Ryan's Pro fields thanks to @gebeer's work. Those Pro fields all need special treatment and you can't expect them to work with just createField().

But you can always fall back to just raw ProcessWire api and create the Combo field with just that. See here how to do it if you got Pro fields support board access. If you don't, here is the code Ryan suggested (hope this is alright to post it here):

image.thumb.png.a27f4dfbfd995d0fc12b3d6f3bafb778.png

You can make a special method for Rock Migrations out of this (should be pretty easy if this code works) and make a PR if you want it there))

Thank you, it indeed works!

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

I did not realize this was an issue. I was able to import a combo field using the declared field parameters.

My code for this particular field looks like the following as a field in the ['fields'] array of the migrate() method call:

                'publication_details' => [
                    'label' => 'Publication Details',
                    'flags' => 0,
                    'type' => 'FieldtypeCombo',
                    'i1_label' => 'Volume',
                    'i1_name' => 'volume',
                    'i1_type' => 'Text',
                    'i2_label' => 'Issue',
                    'i2_name' => 'issue',
                    'i2_type' => 'Text',
                    'i3_label' => 'Year',
                    'i3_name' => 'year',
                    'i3_type' => 'Integer',
                    'i4_label' => 'Period',
                    'i4_name' => 'period',
                    'i4_type' => 'Select',
                    'qty' => 4,
                    'hideWrap' => 0,
                    'useColNames' => 0,
                    'modSchema' => 0,
                    'useDataCol' => 0,
                    'i1_ok' => 1,
                    'i1_collapsed' => 0,
                    'i1_minlength' => 0,
                    'i1_maxlength' => 3,
                    'i1_showCount' => 0,
                    'i1_size' => 3,
                    'i1_stripTags' => 1,
                    'i1_columnWidth' => 25,
                    'i2_ok' => 1,
                    'i2_collapsed' => 0,
                    'i2_minlength' => 0,
                    'i2_maxlength' => 3,
                    'i2_showCount' => 0,
                    'i2_size' => 3,
                    'i2_stripTags' => 1,
                    'i2_columnWidth' => 25,
                    'i3_ok' => 1,
                    'i3_collapsed' => 0,
                    'i3_inputType' => 'number',
                    'i3_size' => 4,
                    'i3_min' => 1600,
                    'i3_columnWidth' => 25,
                    'i4_options' => '=
Month
   Jan
   Feb
   Mar
   Apr
   May
   Jun
   Jul
   Aug
   Sep
   Oct
   Nov
   Dec
Quarter
   Q1
   Q2
   Q3
   Q4',
                    'i4_ok' => 1,
                    'i4_collapsed' => 0,
                    'i4_columnWidth' => 25,
                    'order' => '1,2,3,4',
                    'notes' => 'Include original publication details here.',
                    'columnWidth' => 100,
                ],
            ],

Do note that for the options in order to preserve the options formatting the tabs are specifically positioned.

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