Results 1 to 5 of 5

Thread: hide empty fields (maybe through logic hook...?)

  1. #1
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Wink hide empty fields (maybe through logic hook...?)

    hello friends, I am thinking in how hide some empty fields after create a new record of my module...

    I am in edit view and I have one flex related field, and I need another more... but I have read in sugar guide that this is not possible..., so I will put three (number that I need) related fields in order to fill only one of these three fields in each record
    For example, I have in edit view of my module:
    related field 1
    related field 2
    related field 3
    and I create one new record, and I fill related field 1, so I'd like hide the other two related fields .... I think that through logic hook (of kind before save) can do it. Something like:

    PHP Code:
    if(empty(bean->related_field2)){
    //action to hide this field
    }if(empty(bean->related_field3)){
    //action to hide this field

    how could do this in the best way?
    Thanks again

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: hide empty fields (maybe through logic hook...?)

    I'd recommend a javascript approach. Output some javascript in editviewdefs.php that hides those fields if empty. Then add an event to each field. When that field value changes and has a value then show the next sequential field.

  3. #3
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Default Re: hide empty fields (maybe through logic hook...?)

    Quote Originally Posted by eggsurplus View Post
    I'd recommend a javascript approach. Output some javascript in editviewdefs.php that hides those fields if empty. Then add an event to each field. When that field value changes and has a value then show the next sequential field.
    Hello eggsurplus, thanks for your reply, but I don't understand you...If I hide fields in editviewdefs.php then I can not fill these fields...do you refer to some javascript in detailviewdefs.php,yes?

  4. #4
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: hide empty fields (maybe through logic hook...?)

    Sorry, I misunderstood your needs. You only want to hide them on the detail view if empty. Use a custom view.detail.php and pass a variable to the detailviewdefs.php to set the element as hidden if the value is empty.

  5. #5
    garciasanchezdaniel's Avatar
    garciasanchezdaniel is offline Sugar Community Member
    Join Date
    Aug 2011
    Location
    Spain
    Posts
    403

    Thumbs up Re: hide empty fields (maybe through logic hook...?)

    Quote Originally Posted by eggsurplus View Post
    Sorry, I misunderstood your needs. You only want to hide them on the detail view if empty. Use a custom view.detail.php and pass a variable to the detailviewdefs.php to set the element as hidden if the value is empty.
    Thanks so much eggsurplus!! could you put me any little example?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. hide empty fields through logic hook
    By garciasanchezdaniel in forum Developer Help
    Replies: 5
    Last Post: 2011-11-07, 05:53 AM
  2. Logic hook for calculation with fields from related module
    By Systems Navigator in forum Developer Help
    Replies: 2
    Last Post: 2010-08-20, 08:34 AM
  3. Access to Custom Fields in After Save Logic Hook
    By chad.hutchins in forum Developer Help
    Replies: 4
    Last Post: 2010-05-11, 03:42 PM
  4. Disable fields from the logic hook
    By ishaan in forum Developer Tutorials
    Replies: 4
    Last Post: 2009-06-15, 12:09 PM
  5. Logic Hook php error when testing default fields
    By ptemplin7 in forum Developer Help
    Replies: 4
    Last Post: 2008-05-29, 03:31 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
  •