Skip to content

Instantly share code, notes, and snippets.

@betobaz
Created March 13, 2014 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betobaz/9533729 to your computer and use it in GitHub Desktop.
Save betobaz/9533729 to your computer and use it in GitHub Desktop.
fill_dropdown_custom
<?php
/*********************************************************************************
* By installing or using this file, you are confirming on behalf of the entity
* subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
* the SugarCRM Inc. Master Subscription Agreement (“MSA”), which is viewable at:
* http://www.sugarcrm.com/master-subscription-agreement
*
* If Company is not bound by the MSA, then by installing or using this file
* you are agreeing unconditionally that Company will be bound by the MSA and
* certifying that you have authority to bind Company accordingly.
*
* Copyright (C) 2004-2013 SugarCRM Inc. All rights reserved.
********************************************************************************/
// THIS CONTENT IS GENERATED BY MBPackage.php
$manifest = array (
0 =>
array (
'acceptable_sugar_versions' =>
array (
0 => '7.1.*',
),
),
1 =>
array (
'acceptable_sugar_flavors' =>
array (
0 => 'PRO',
1 => 'ENT',
),
),
'readme' => '',
'key' => '',
'author' => 'Pedro Alberto Bazan Serrano',
'description' => 'Crea, actualiza y reemplaza listas desplegables',
'icon' => '',
'is_uninstallable' => true,
'name' => 'fill_dropdown',
'published_date' => '2013-12-03 11:05:23',
'type' => 'module',
'version' => '0.1',
);
$installdefs = array (
'id' => 'fill_dropdown',
);
$app_list_strings_custom = array (
array (
"name" => "my_list_01",
"list" => array(
"" => "",
"1" => "1",
"2" => "2",
"3" => "3",
),
),
array (
"name" => "my_list_02",
"list" => array(
"" => "",
"a" => "a",
"b" => "b",
"c" => "c",
),
),
);
<?php
require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
require_once('modules/ModuleBuilder/parsers/parser.dropdown.php');
function post_install()
{
global $app_list_strings, $current_language;
include "app_list_strings_custom.php";
$_REQUEST['view_package'] = 'studio';
foreach ($app_list_strings_custom as $list_data) {
$listEncode = encodeList($list_data['list']);
$list = "[".implode(",", $listEncode)."]";
$parserDropDown = new ParserDropDown();
$parserDropDown->saveDropDown(array(
'dropdown_lang' => $current_language,
'dropdown_name' => $list_data['name'],
'view_package' => 'studio',
'view_module' => '',
'list_value' => $list,
));
"<br> Lista guardada: " . $list_data['name'];
}
}
function encodeList($list){
$listEncode = array();
foreach($list as $key => $item ){
$listEncode[] = <<<text
["$key","$item"]
text;
}
return $listEncode;
}
@infospectrum
Copy link

Module Loader says successful install (v6.5.5 Enterprise), but in dropdown editor my_list_01,my_list_02 are not present...

@sonesay
Copy link

sonesay commented May 27, 2014

Yes I get the same issue with drop-down list not showing. Can you also supply the origin reference material for creating these types of packages?

Edit found problem
"Hi finally have it working. Just wanted to point out you had to put the script in the scripts folder respectively. I think Pedro could not show files in folders with the online source code he was sharing so he used scripts__filename instead.

There was also another error where the array list of drop-down lists php file had no opening and closing php tags."

@betobaz
Copy link
Author

betobaz commented May 27, 2014

Hi sonesay,

Like eggsurplus says, the best way is to add the options in a languaje file and leave the package manager install it.

I hope work in this modification in these days.

@mehulsbhandari
Copy link

How do i delete cache folder from here.. ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment