Results 1 to 6 of 6

Thread: A datefield that only shows/saves the Year

  1. #1
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default A datefield that only shows/saves the Year

    Hi,

    Is it possible to include a date field that will only show and store the year in the DB. If not I can achieve this using a Dropdown that I populate initially but would then need some sort of custom code to add the new Year when its required.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  2. #2
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,597

    Default Re: A datefield that only shows/saves the Year

    Just write the following code to your /custom/include/language/en_us.lang.php (and other language files if you have some) or to an extension language file.

    PHP Code:
    $year_start 2000;
    $year_end date("Y")+1;
    for (
    $i=$year_start;$i<=$year_end;$i++)
    {
        
    $GLOBALS['app_list_strings']['YEAR_list'][$i]=$i;

    The code creates a dropdown running from year_start to the year following the current year.
    Harald Kuske
    Pre-Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com


  3. #3
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: A datefield that only shows/saves the Year

    Hi,

    That is perfect, quick question which language file to I include it in. Which language file is best or does it really matter?

    Also when the new options are included how do I make it keep my sort order so that the oldest Year is always at the bottom?

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  4. #4
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010
    Location
    Serbia
    Posts
    396

    Default Re: A datefield that only shows/saves the Year

    Quote Originally Posted by kuske View Post
    Just write the following code to your /custom/include/language/en_us.lang.php (and other language files if you have some) or to an extension language file.

    PHP Code:
    $year_start 2000;
    $year_end date("Y")+1;
    for (
    $i=$year_start;$i<=$year_end;$i++)
    {
        
    $GLOBALS['app_list_strings']['YEAR_list'][$i]=$i;

    The code creates a dropdown running from year_start to the year following the current year.
    Very nice sharing, thx for it
    CRM Software Engineer
    Eontek - www.eontek.rs

  5. #5
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,597

    Default Re: A datefield that only shows/saves the Year

    You can put it in each language file if you want.
    It makes no trouble if it runs more than one time.
    Harald Kuske
    Pre-Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com


  6. #6
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: A datefield that only shows/saves the Year

    Hi,

    Thanks. Last think now that I have it in is how to sort the order of the dates? I assume looking at hte For loop, it will be sorted from oldest year to newest?


    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Can't access datefield (dropdown menu)
    By knoop in forum Developer Help
    Replies: 1
    Last Post: 2010-09-01, 10:00 AM
  2. Search Datefield
    By bob1965 in forum Help
    Replies: 2
    Last Post: 2009-12-11, 04:02 PM
  3. slow saves from one client machine
    By electromike in forum Help
    Replies: 0
    Last Post: 2008-12-04, 05:26 PM
  4. jotpad saves only on logout
    By davem in forum Help
    Replies: 1
    Last Post: 2007-10-12, 02:42 AM
  5. Replies: 0
    Last Post: 2005-11-08, 04:28 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
  •