Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7712885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:44:12+00:00 2026-06-01T01:44:12+00:00

I’m trying to pretty-up a dropdown field, and I’m not sure I’m taking the

  • 0

I’m trying to pretty-up a dropdown field, and I’m not sure I’m taking the right approach. I have this model for which the field ‘type’ is to be a dropdown that displays a string, but stores an integer. To format the output, I’ve subclassed Grid as

class Model_Member extends MVCTable {
    function init() {
        parent::init();

        $this->addField('type')
            ->type('list')
            ->display(array('grid'=>'mbrtype'))
            ->caption('Member Type')
            ->listData(array('Guest','Associate','Full'))
            ;
    }
}

To format the output, I’ve subclassed Grid as

class Grid extends Grid_Basic {
    function format_mbrtype($field) {
        $mt=array('Guest','Associate','Full');
        $this->current_row[$field]=$mt[$this->current_row[$field]];
    }
}

When I load Member records my admin CRUD, I see this field populated with the numbers instead of the formatted data. I had expected the Controller to pick up the values passed into display() and execute my formatter instead of using the standard one.

Am I missing something here? I poked through the source, and my best guess as to the spot where things are going wrong is in MVCGrid.php, line 45. The call to formatType() on the Controller object does not include the field name as the third argument, which causes it to ignore the field’s display collection’s mappings and fall back to the Controller’s $type_correspondence array.

Of course, I’ve only been working with ATK4 for a couple weeks now, so I may have just tied things together wrong. Is this the correct way of implementing a custom formatter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:44:13+00:00Added an answer on June 1, 2026 at 1:44 am

    there is a problem in ATK 4.1.3:

    There was actually a problem. You’ll need to patch atk4-addons:

    diff --git a/mvc/MVCGrid.php b/mvc/MVCGrid.php
    index 90bd365..0fb0c0b 100644
    --- a/mvc/MVCGrid.php
    +++ b/mvc/MVCGrid.php
    @@ -42,7 +42,7 @@ class MVCGrid extends Grid{
                    $field=$this->getController()->getModel()->getField($field_name);
                    if(is_null($field))throw new Exception_InitError("Field '$field_name' is not defined in the ".
                            get_class($this->getController()->getModel())." model");
    -               if(is_null($type))$type=$this->getController()->formatType($field->datatype(),'grid');
    +               if(is_null($type))$type=$this->getController()->formatType($field->datatype(),'grid',$field_name);
                    if($field_name=='locked')return
                            parent::addColumn('locked','locked','');
             if($field_name=='id')$type='text';
    

    Or open atk4-addons/mvc/MVCGrid.php, and on line 45, add 3rd argument to the call of formatType(….., $field_name);

    and that should work.

    Alternatively

    Upgrade atk4-addons to the “master” in github, which is still on 4.1 branch.

    Demo: http://codepad.agiletoolkit.org/myformat

    The correct way to defining “display” field is through array(‘grid’=>’myfield’);

    Thanks for noticing the problem!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to understand how to use SyndicationItem to display feed which is
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.