Jump to content

Creating a FieldtypeCombo using RockMigrations causes problems


nloyola
 Share

Recommended Posts

When I create a FieldtypeCombo using RockMigrations I get the following error when I try to add the combo to a page:

PagesEditor: Error saving field "Options" — SQLSTATE[42S22]: Column not found: 1054 Unknown column 'i1' in 'field list'

Here is the code I use to create the field:
 

        $this->rm()->createField('wrapper_options', 'FieldtypeCombo', [
            'tags' => self::TAG,
            'label' => 'Options',
            'flags' => '0',
            'i1_label' => 'Tag Type',
            'i1_name' => 'tag_type',
            'i1_type' => 'Select',
            'qty' => '4',
            'hideWrap' => '0',
            'collapsed' => '0',
            'useColNames' => '0',
            'modSchema' => '0',
            'useDataCol' => '0',
            'i1_options' => '+div
section',
            'i1_ok' => '1',
            'i1_collapsed' => '0',
            'i1_columnWidth' => '25',
            'order' => '1,2,3,4',
            'i2_label' => 'Background',
            'i2_name' => 'background',
            'i2_type' => 'Select',
            'i2_options' => '+None
Color
Gradient
Image',
            'i2_ok' => '1',
            'i2_collapsed' => '0',
            'i2_columnWidth' => '25',
            'i3_label' => 'Width',
            'i3_name' => 'width',
            'i3_type' => 'Select',
            'i3_options' => '+Full Width
Max Width',
            'i3_ok' => '1',
            'i3_collapsed' => '0',
            'i3_columnWidth' => '25',
            'i4_label' => 'Spacing',
            'i4_name' => 'spacing',
            'i4_type' => 'Select',
            'i4_options' => '+Padding
Margin',
            'i4_ok' => '1',
            'i4_collapsed' => '0',
            'i4_columnWidth' => '25',
        ]);

If I edit the field using the PW admin dashboard, and then save it, the problem goes away. I.e. the field is created properly in the database.

Am I missing something when creating the field using RockMigrations?

Thank you

  • Like 1
Link to comment
Share on other sites

I fixed the problem by creating the field with the ComboField class. E.g.

        $f = new ComboField();
        $f->type = $this->modules->get("FieldtypeCombo");
        $f->name = 'heading_options';
        $f->label = 'Options';
        $f->addable = 1;
        $f->tags = self::TAG;

        $f->i1_label = 'Class';
        $f->i1_name = 'class';
        $f->i1_type = 'Select';
        $f->i1_ok = '1';
        $f->i1_collapsed = '0';
        $f->i1_columnWidth = '50';
        $f->i1_options = '+heading-copy=Copy
heading-secondary--a=Secondary A
heading-secondary--b=Secondary B';
        $f->save();

        $this->rm()->getField('heading_options')->save();

 

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