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

Using native fieldtypes in Publish Tab EE2 addon development

Development and Programming

Jack McDade's avatar
Jack McDade
425 posts
about 16 years ago
Jack McDade's avatar Jack McDade

Maybe I missed something in the documentation, and this might not be the right forum, but here we go. I’m working on a module for EE2 and am using the Tab File to create a Publish tab with various options and settings, most of which are select boxes. I have two issues:

1) I can’t seem to pre-populate the dropdown with the selected option from the DB. Using http://expressionengine.com/public_beta/docs/development/modules.html#tab_file as a reference, i’m passing the ID of the selected field through the ‘selected’ => array element, but no dice.

Here’s my code:

// For example's sake: $field_id = '2';
// For example's sake: $fields = array('field_1' => 'Field 1', 'field_2' => 'Field 2'); 

$settings[] = array(
    'field_id'        => 'field_id',
    'field_label'        => $this->EE->lang->line('fields'),
    'field_required'     => 'n',
    'field_data'        => '',
    'field_list_items'    => $fields,
    'selected'        => $field_id,
    'field_fmt'        => 'text',
    'field_instructions'     => '',
    'field_show_fmt'    => 'n',
    'field_fmt_options'    => array(),
    'field_pre_populate'    => 'n',
    'field_text_direction'    => 'ltr',
    'field_type'         => 'select'
    );

2) My publish tab is lowercase and i cannot make it Title Case no matter how hard i try. Where exactly is that name pulled from? Documentation wasn’t clear.

Hoping someone has some thoughts. Thanks!

uMoved to Modules by Moderator

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 16 years ago
Sue Crocker's avatar Sue Crocker

Moving to the right forum..

       
Jack McDade's avatar
Jack McDade
425 posts
about 16 years ago
Jack McDade's avatar Jack McDade

So, is there no EllisLab support available for EE2 add-on development questions?

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 16 years ago
Sue Crocker's avatar Sue Crocker

No, there isn’t. Some of the TSS staff has experience with programming add ons, but many of us don’t. It’s outside of the scope of what we do. We also don’t offer support for HowTo questions, but if we have time we’ll answer those.

       
Jack McDade's avatar
Jack McDade
425 posts
about 16 years ago
Jack McDade's avatar Jack McDade

That’s a shame. I guess i assumed addon development was pretty important to you guys, especially since it’s one of the largest barriers to full on EE 2.0 adoption.

If someone does have the time to give me a How To on why following the docs doesn’t work, i’d appreciate it. Otherwise i guess i’ll just plow ahead on my own. Thanks Sue.

       
Jack McDade's avatar
Jack McDade
425 posts
about 16 years ago
Jack McDade's avatar Jack McDade

In case anyone runs into this, i figured out the pre-selection for native select boxes. Took longer than i’d like.

You need to pass the selected option in an array, and map it to the “field_data” element in your fieldtype array.

e.g.

$selected = array();
$selected[] = 3;

$settings[] = array(
    'field_id'        => 'field_id',
    'field_label'        => $this->EE->lang->line('fields'),
    'field_required'     => 'n',
    'field_data'        => $selected,
    'field_list_items'    => $fields,
    'field_fmt'        => 'text',
    'field_instructions'     => '',
    'field_show_fmt'    => 'n',
    'field_fmt_options'    => array(),
    'field_pre_populate'    => 'n',
    'field_text_direction'    => 'ltr',
    'field_type'         => 'select'
    );
       

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.