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
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.
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'
);Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.