We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to create a new fieldtype that sets it's DB column to int

Development and Programming

Brian Litzinger's avatar
Brian Litzinger
693 posts
6 years ago
Brian Litzinger's avatar Brian Litzinger

I mentioned this on Slack the other day but no one has responded, so I’ll try here.

I’m making a new add-on and it saves only an integer value in the CP, and when the field is created, it sets the DB column to text, not int. How can I set the column to int? I tried this but it does not work.

public function save_settings($settings)
    {
        return [
            'field_content_type' => 'integer', // I tried 'int' too
            'field_fmt' => 'none',
            'field_show_fmt' => 'n',
            'field_wide' => true,
        ];
    }
       
Robin Sowell's avatar
Robin Sowell
13,158 posts
6 years ago
Robin Sowell's avatar Robin Sowell

Does EE_Fieldtype::settings_modify_column($data) do the trick?

       
Brian Litzinger's avatar
Brian Litzinger
693 posts
6 years ago
Brian Litzinger's avatar Brian Litzinger

I wasn’t aware of that, thanks! I’ll give it a shot and let you know.

       
Brian Litzinger's avatar
Brian Litzinger
693 posts
6 years ago
Brian Litzinger's avatar Brian Litzinger

That did the trick! Thanks

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.