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

Thread: Show field 'date' when field 'checkbox' is true

  1. #1
    fbrites is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Lisbon, Portugal
    Posts
    77

    Default Show field 'date' when field 'checkbox' is true

    Hi,

    In module 'Project' I created custom fields to manage the stages of Projects.

    I create custom fields type date and checkbox. I want that when the 'checkbox' = '1', appear the field date.
    When the 'checkbox' ='0 ', doesn't appear the field date.

    For example, in image http://www.dibconsulting.com/sites/images/check.jpg describes what I want:

    - When 'Aceitacao Cliente' = '1 '=> Shows' Data Aceitacao'
    - When 'Inicio Trabalhos' = '0' => no shows' Data Inicio'
    - And it the same for other fields.

    Someone can help me?

    Thank you
    Last edited by fbrites; 2008-06-20 at 09:18 AM.
    Fábio Brites
    <Sugar 6.>
    <Windows XP>

  2. #2
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Show field 'date' when field 'checkbox' is true

    This is possible, but not via built-in functionality. You would need to add some custom JavaScript to the desired page which in turn evaluates whether or not the box is being checked/unchecked and then hides/displays the date field accordingly.
    Regards,

    Angel Magaña
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  3. #3
    fbrites is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Lisbon, Portugal
    Posts
    77

    Default Re: Show field 'date' when field 'checkbox' is true

    Thanks Angel,

    I read some theards and I know that it is necessary to customize JavaScript.

    I only have to customize the file 'module_name.js' and 'editviewdefs.php'? Or I have to also customize file 'editview.php'?

    Thank you
    Last edited by fbrites; 2008-06-19 at 10:54 AM.
    Fábio Brites
    <Sugar 6.>
    <Windows XP>

  4. #4
    fbrites is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Lisbon, Portugal
    Posts
    77

    Default Re: Show field 'date' when field 'checkbox' is true

    I found one thread with what I wanted to do: http://www.sugarcrm.com/forums/showthread.php?t=24864 (thanks Andopes).

    I want to enable and disable the date field based on the selection of the checkbox. If the check box is selected, the date field is selected and if the check box is not selected then the date field is disabled.

    I'm working with SugarCRM 5.0.0e and in this version doesn't have file 'editview.html'.

    What files I do this?

    Thanks
    Fábio Brites
    <Sugar 6.>
    <Windows XP>

  5. #5
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Show field 'date' when field 'checkbox' is true

    Quote Originally Posted by fbrites
    Thanks Angel,

    I read some theards and I know that it is necessary to customize JavaScript.

    I only have to customize the file 'module_name.js' and 'editviewdefs.php'? Or I have to also customize file 'editview.php'?

    Thank you
    Hi,
    You just need to modify editviewdefs.php adding a javascript call with onchange method and an include of your external .js file. Then edit your .js file adding the function to hide/show the date field.
    At the end, clear template data cache and rebuild relationships.
    What do you think the cookie monster eats ?

  6. #6
    fbrites is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Lisbon, Portugal
    Posts
    77

    Default Re: Show field 'date' when field 'checkbox' is true

    Thanks Dragonfly,

    I try to do this.

    So, you can give me an for example for my case?

    thank you very much
    Fábio Brites
    <Sugar 6.>
    <Windows XP>

  7. #7
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Show field 'date' when field 'checkbox' is true

    Quote Originally Posted by fbrites
    Thanks Dragonfly,

    I try to do this.

    So, you can give me an for example for my case?

    thank you very much
    For the javascript function, you can try the one suggested by Andopes in the other thread you mentioned.
    For editviewdefs.php you can try something like this:
    PHP Code:
    ...
            
    'includes' => 
            array (
              
    => 
              array (
                
    'file' => 'custom/include/javascript/myJavascript.js'//change path and filename with yours
              
    ),
            ),
     ),
          
    'panels' => 
          array (
    ...
                array (
                  
    'name' => 'mycheckbox_c'// or whatever it's called
                  
    'label' => 'LBL_MYCHECKBOX'// or whatever it is
                  
    'displayParams' => array (
                                                  
    'javascript' => 'onchange="myfunction();"' //change with your function's name
                                                  
    ),
                ),
    ... 
    What do you think the cookie monster eats ?

  8. #8
    fbrites is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Lisbon, Portugal
    Posts
    77

    Default Re: Show field 'date' when field 'checkbox' is true

    Thanks Dragonfly...

    I try to do this.

    Thanks
    Fábio Brites
    <Sugar 6.>
    <Windows XP>

  9. #9
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Show field 'date' when field 'checkbox' is true

    Quote Originally Posted by fbrites
    Thanks Dragonfly...

    I try to do this.

    Thanks
    You are welcome.
    Please let me know about your results.
    What do you think the cookie monster eats ?

  10. #10
    fbrites is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Lisbon, Portugal
    Posts
    77

    Default Re: Show field 'date' when field 'checkbox' is true

    Hi Dragonfly,

    I'm having some problems.

    I think I'm committing an error in the .js file.

    I am following the Andolopes thread but I must be doing something wrong.

    You can write me the .js code as done in previous thread?

    Thanks Dragonfly
    Fábio Brites
    <Sugar 6.>
    <Windows XP>

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. Replies: 18
    Last Post: 2008-04-15, 01:18 PM
  2. BUG? Field layout - Start Date
    By Smoked Caramel in forum Help
    Replies: 6
    Last Post: 2006-07-25, 02:23 PM
  3. Replies: 1
    Last Post: 2006-06-16, 03:35 AM
  4. Creating Custom Field - Checkbox
    By ethanb in forum Help
    Replies: 2
    Last Post: 2005-07-11, 08:55 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
  •