Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: subpanel format - value field

  1. #1
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default subpanel format - value field

    I have a value field in a custom module and I want it to display 2 decimal place in a subpanel

    ie 64 display as 64.00

    How can I do this?

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: subpanel format - value field

    Hi, mikesolomon

    You can override into your module Class the function get_list_view_array, located into data/SugarBean.php
    You can use the function format_number into modules/Currencies/Currency.php for formating the value and insert into $return_array.

    Cheers


    --
    André Lopes
    Lâmpada Global Services
    Rua Bela Cintra, 299 conjunto. 51
    São Paulo, SP 01415-000
    tel1. 55 11 3237-3110
    cel. 55 11 7636-5859
    e-mail: info@lampadacrm.com.br

  3. #3
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: subpanel format - value field

    Quote Originally Posted by andopes
    Hi, mikesolomon

    You can override into your module Class the function get_list_view_array, located into data/SugarBean.php
    You can use the function format_number into modules/Currencies/Currency.php for formating the value and insert into $return_array.

    Cheers


    --
    André Lopes
    Lâmpada Global Services
    Rua Bela Cintra, 299 conjunto. 51
    São Paulo, SP 01415-000
    tel1. 55 11 3237-3110
    cel. 55 11 7636-5859
    e-mail: info@lampadacrm.com.br
    Thanks

    Are you saying take get_list_view_array from data/SugarBean.php and put it into my module?

    must admit I'm a bit confused on what I need to do

  4. #4
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: subpanel format - value field

    Hi, mikesolomon

    You have to define this same function under your module, this one will call the parent function (SugarBean function) and after this modify the $return_array according to your needs.

    Cheers

    --
    André Lopes
    Lâmpada Global Services
    Rua Bela Cintra, 299 conjunto. 51
    São Paulo, SP 01415-000
    tel1. 55 11 3237-3110
    cel. 55 11 7636-5859
    e-mail: info@lampadacrm.com.br

  5. #5
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: subpanel format - value field

    Perfect - that works perfectly

    On the same note how can I align a value field right in the subpanel - at the moment it is aligned left

  6. #6
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: subpanel format - value field

    Hi, mikesolomon

    I believe it is possible, but not right easy to do.
    Take a look at the script include/SubPanel/SubPanel.php

    The listview view use the $params array for deciding how to render a listview row, perhaps the subpanel use the same strategy.

    Cheers

    --
    André Lopes
    Lâmpada Global Services
    Rua Bela Cintra, 299 conjunto. 51
    São Paulo, SP 01415-000
    tel1. 55 11 3237-3110
    cel. 55 11 7636-5859
    e-mail: info@lampadacrm.com.br

  7. #7
    clint's Avatar
    clint is offline Sugar Team Member | Forums Lead Moderator
    Join Date
    Aug 2004
    Location
    Silicon Valley
    Posts
    2,120

    Default Re: subpanel format - value field

    Have you tried the simple route of simply setting the "Precision" value on the custom field defintion? In Studio when you create a custom field of type Decimal, you can set the Precision value which determines the number of decimal places to display for that field.
    Sugar Developer Zone - developer resources | Sugar University - user and admin training
    Sugar Docs - user and admin documentation |
    Sugar Bug Tracker - Enter or view bugs
    SugarForge- open source modules, themes, lang packs | SugarExchange - commercial extensions

    Clint Oram
    Chief Technology Officer and Co-founder
    SugarCRM

  8. #8
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: subpanel format - value field

    Quote Originally Posted by clint
    Have you tried the simple route of simply setting the "Precision" value on the custom field defintion? In Studio when you create a custom field of type Decimal, you can set the Precision value which determines the number of decimal places to display for that field.
    I set the precision to 2 but it didnt seem to work - when I look at the field in module builder it has a precision of 2 but in mysql it shows as - FLOAT(12,0)

    Looks like the module builder is not creating the field properly

    Anyway it is working now

    Just got to work out how to align values right in the subpanel

  9. #9
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: subpanel format - value field

    Quote Originally Posted by clint
    Have you tried the simple route of simply setting the "Precision" value on the custom field defintion? In Studio when you create a custom field of type Decimal, you can set the Precision value which determines the number of decimal places to display for that field.
    This appears to be a bug

    The Vardefs entry is

    'value' =>
    array (
    'required' => false,
    'name' => 'value',
    'vname' => 'LBL_VALUE',
    'type' => 'float',
    'massupdate' => 0,
    'comments' => '',
    'help' => '',
    'duplicate_merge' => 'disabled',
    'duplicate_merge_dom_value' => 0,
    'audited' => 0,
    'reportable' => 0,
    'len' => '18',
    'precision' => '2',
    ),

    but that creates a field in mysql

    `value` FLOAT(12,0) DEFAULT NULL,

    so len & precision are being ignored

  10. #10
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: subpanel format - value field

    Hi, mikesolomon

    The len of the field seems to be so big. I'm not sure it is the cause of trouble, but....

    Try to redefine the fields def to len like 12 and precision 2..

    Repair database and check the change into database.

    Cheers

    --
    André Lopes
    Lâmpada Global Services
    SugarCRM Silver Partner
    USA: +1 908 998-2278
    BR: +55 11 3237-3110
    www.lampadaglobal.com
    email: info@lampadaglobal.com

    Lampada Global Services delivers enterprise software and offshore programming services to customers around the world.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Subpanel field format - SugarCRM 5
    By nicholak in forum Help
    Replies: 10
    Last Post: 2010-03-04, 07:22 PM
  2. HOWTO - Hack Sugar to support related module info in subpanel (one-many)
    By kenneth.thorman in forum Developer Tutorials
    Replies: 35
    Last Post: 2008-06-10, 07:51 AM
  3. subpanel issues for a related field
    By ptemplin7 in forum Help
    Replies: 6
    Last Post: 2008-03-25, 10:13 AM
  4. Replies: 2
    Last Post: 2006-07-30, 01:34 AM
  5. Subpanel field layout
    By skovron in forum Help
    Replies: 1
    Last Post: 2006-02-10, 01:37 AM

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
  •