Results 1 to 9 of 9

Thread: Custom multiselect problem

  1. #1
    antoinebelmont is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    33

    Exclamation Custom multiselect problem

    Good day to all:

    I'm doing a custom multiselect within the meetings module, it display a list of available accounts from accounts module, i made the list within the view.edit.php file, the field already saves and display selected values very well, but, i don't know how to display the values within the detail view, i seek around the google and forums, but i dont know how to do it, may you help me please, any kind of help its welcome, thanks for advanced

  2. #2
    jmertic's Avatar
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    3,996

    Default Re: Custom multiselect problem

    Why not use the OOTB multiselect?
    John Mertic
    Sugar Community Manager

  3. #3
    antoinebelmont is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    33

    Default Re: Custom multiselect problem

    Quote Originally Posted by jmertic View Post
    Why not use the OOTB multiselect?
    thanks for your answer, i don't know about the OOTB (that means out-of-the-box right?), but searching, i found many of your post's talking about things like my problem, following this post solution Accessing Field Data on Current Record, i made the steps related by Bcdev but my field is still taking the values from the static list instead the dynamic list made with the function, this is my code:

    [sugarcrm]\custom\include\utils.php:
    PHP Code:
    function getAccountsName($focus){
        
    $query "SELECT id, name FROM accounts WHERE deleted = 0";
        
    $result $GLOBALS['db']->query($queryfalse);
        
    $list = array();
        
    $list[''] = '';
        
        while((
    $row $focus->db->fetchByAssoc($result)) != null){
            
    $list[$row['id']] = $row['name'];
        }
        return 
    $list;


    [sugar]\custom\Extension\modules\Meetings\Ext\Vardefs\sug arfield_cuentas_c:
    PHP Code:
    <?php
     
    // created: 2012-07-30 16:52:03
         
    unset($dictionary['Meetings']['fields']['cuentas_c']['options']);
        
    $dictionary['Meetings']['fields']['cuentas_c']['function']='getAccountsName';
     
    ?>
    i'm loosing any step? thanks for your help.

  4. #4
    jmertic's Avatar
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    3,996

    Default Re: Custom multiselect problem

    The second file needs a .php extension, but otherwise doing a Quick Repair and Rebuild afterwards should solve it.
    John Mertic
    Sugar Community Manager

  5. #5
    antoinebelmont is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    33

    Default Re: Custom multiselect problem

    Quote Originally Posted by jmertic View Post
    The second file needs a .php extension, but otherwise doing a Quick Repair and Rebuild afterwards should solve it.
    Ups, a finger error, already that have it, searching for another solution, i made a custom view.edit.php within
    [sugarcrm]\custom\modules\Meetings\views\
    with this code:
    PHP Code:
    $cuentas = array();
            
    $db =  DBManagerFactory::getInstance();
            
    $query "SELECT id, name FROM accounts WHERE deleted = 0";
            
    $result $db->query($querytrue'Error');
            
            while(
    $row $db->fetchByAssoc($result)){
                
    $cuentas[$row['id']]=$row['name'];
            }
            
    $this->ss->assign('myOptions'$cuentas);
            
    $query 'SELECT cuentas_c FROM meetings_cstm WHERE id_c="'.$this->bean->id.'"';
            
    $result $db->query($querytrue'Error');
            
    $cuentas $db->fetchByAssoc($result);
            
    $cuentasSeleccionadas $cuentas['cuentas_c'];
            
    $cuentasSeleccionadas explode("^",$cuentasSeleccionadas);
            
    $this->ss->assign('mySelect',$cuentasSeleccionadas);
            
    $handle fopen("pruebaCuentas.txt","a+");
            
    fwrite($handle$cuentasSeleccionadas[0]."\n"); 
    and then put customCode within the field definition:
    PHP Code:
    'customCode' =>'<select multiple = "multiple" id="cuentas_c[]" name="cuentas_c[]">
                                    <option value="null">-- none --</option>
                                    {html_options options=$myOptions selected=$mySelect}
                                </select>'

    that works!:
    Name:  501ae15adbf3ec123d00002e.jpeg
Views: 350
Size:  8.6 KB
    But within the detail view a don't know how to made it:
    Name:  501add20dbf3ec1c70000002.jpeg
Views: 376
Size:  4.1 KB
    What of this posible solutions are easier? thanks for the help
    Attached Images Attached Images   

  6. #6
    jmertic's Avatar
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    3,996

    Default Re: Custom multiselect problem

    John Mertic
    Sugar Community Manager

  7. #7
    antoinebelmont is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    33

    Default Re: Custom multiselect problem

    thanks, i already try that solution, in fact its my first code snippet posted here, but when i do quick rebuild don't do nothing, by now i gonna modify the detail view with javascript until i found a solution, thanks for your time and your help

  8. #8
    newroseji Guest

    Default Re: Custom multiselect problem

    Quote Originally Posted by antoinebelmont View Post
    thanks, i already try that solution, in fact its my first code snippet posted here, but when i do quick rebuild don't do nothing, by now i gonna modify the detail view with javascript until i found a solution, thanks for your time and your help
    Did you fix that problem? I am also having more or less similar problem.

    My problem is - I have created multiselect dropdown that gets filled via database call on the fly. I am not able to save that to database (I get it that I do not have database that can shore all one-to-many relationship data). But, I want to show all selected field (from multiselect dropdown) as a field in detailView.
    How to do that?
    Need help.
    Thanks in advance.

  9. #9
    xfasfdsfg Guest

    Default Re: Custom multiselect problem

    i already try that solution, in fact its my first code snippet posted here, but when i do quick rebuild don't do nothing, by now i gonna modify the detail view with javascript until i found a solution, thanks for your time and your help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. problem with custom multiselect field in search
    By smilee in forum Developer Help
    Replies: 6
    Last Post: 2011-10-04, 04:06 PM
  2. Default value for multiselect custom field
    By aliceroth in forum Help
    Replies: 2
    Last Post: 2010-07-02, 01:58 PM
  3. custom ACLRoles popup but no multiselect
    By kblackwell in forum Developer Help
    Replies: 1
    Last Post: 2010-04-24, 08:42 PM
  4. BIG Problem with customCode and MultiSelect
    By z3r0 in forum Developer Help
    Replies: 20
    Last Post: 2009-07-09, 03:02 PM
  5. Changiing custom dropdown to Multiselect
    By SVydelingum in forum Developer Help
    Replies: 1
    Last Post: 2009-05-28, 10:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •