Results 1 to 8 of 8

Thread: a dropdown as a required field

  1. #1
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,100

    Default a dropdown as a required field

    Hi,

    I'm having an odd issue with custom dropdowns.

    What I want to achieve is a dropdown of items - lets call them territories. I was users to pick a territory (europe, amiercas, asia) and so I want the field to be 'required'. However, i don't want it to default to any of the items. So ideally, when creating the record, the field is blank but the user needs to pick one of the three values for the system to be able to save the record.

    Now, if I create the dropdown with the three values (europe, americas, asia) and mark the field as required - then when creating the record, it defaults to europe (the first item in the list). If I add an empty item to the top of the dropdown (so it displays as "-blank- [-blank-]" - then the list looks empty when the record is created -but the system lets the blank value be saved.

    Is the the standard behaviour? It's a custom module with a custom field - but I've retrospectively set it as required via the custom vardefs.

    Any thoughts welcome.

  2. #2
    crmsiva's Avatar
    crmsiva is offline A Sugar Hero
    Join Date
    Jan 2009
    Location
    Chennai, India
    Posts
    1,130

    Default Re: a dropdown as a required field

    Hi

    This is strange. Generally, blank values are stored as '' => '' in the file custom/include/language/en_us.lang.php. Make sure it is stored as same.

    To make a field as required one, you can simply change in editviewdefs.php?

  3. #3
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,100

    Default Re: a dropdown as a required field

    Hi,

    Yes - the fist entry in custom/include/language/en_us.lang.php is '' => ''.

    And in e custom editviewdefs.php, the array for that field contains:

    Code:
                'displayParams' =>
                array (
                  'required' => true,
                ),
    On editing, the field has the red asterisk. it's just that it seems to treat ''=>'' as a regular value.

  4. #4
    crmsiva's Avatar
    crmsiva is offline A Sugar Hero
    Join Date
    Jan 2009
    Location
    Chennai, India
    Posts
    1,130

    Default Re: a dropdown as a required field

    Since it is a custom field. You can set is as required one through studio?

    May be problem is due to the code change you have made in custom vardefs.

    Interface is displaying the text -blank- ? Could you post a screenshot to understand better?

  5. #5
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,100

    Default Re: a dropdown as a required field

    Hi,

    No, it's showing no text - just the empty row in the drop down. here's a screenshot of the editview when creating a new record - I've opened up the dropdown (subscription country) and you can see that the first item is the blank row.
    Attached Images Attached Images  

  6. #6
    crmsiva's Avatar
    crmsiva is offline A Sugar Hero
    Join Date
    Jan 2009
    Location
    Chennai, India
    Posts
    1,130

    Default Re: a dropdown as a required field

    Hi

    Very strange. Could you upload custom language file and editviewdefs file? So that i can have a look.

  7. #7
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,100

    Default Re: a dropdown as a required field

    Sure - here's the editviewdefs file and the relevant section from the custom language file (I'm afraid there is some private details in the full file so I had to cut those out).

    Some of the countries have odd characters which might appear strange depending on your editor.

    Thanks for this,
    Attached Files Attached Files

  8. #8
    crmsiva's Avatar
    crmsiva is offline A Sugar Hero
    Join Date
    Jan 2009
    Location
    Chennai, India
    Posts
    1,130

    Default Re: a dropdown as a required field

    I couldn't able to reproduce the problem using the attached files. Very strange..

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 13
    Last Post: 2010-12-03, 11:17 AM
  2. Replies: 18
    Last Post: 2010-05-05, 09:21 AM
  3. Replies: 3
    Last Post: 2009-11-18, 11:59 PM
  4. Replies: 7
    Last Post: 2007-07-13, 01:38 PM
  5. Set the 'Assigned to' field to a Required Field
    By MIConsultancy in forum Help
    Replies: 1
    Last Post: 2007-07-05, 08:22 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
  •