Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dominic Kelly 114 posts 133 karma points
    Feb 04, 2012 @ 14:52
    Dominic Kelly
    0

    Dropdown list - first option is empty??

    Mt drop down field is defined thus:

    http://screencast.com/t/ZaERkFHhM4J

    The outputted HTML appears like so:

    http://screencast.com/t/CNiGStaba

    Why is there an empty first option? 

  • Dominic Kelly 114 posts 133 karma points
    Feb 05, 2012 @ 20:46
    Dominic Kelly
    0

    Anyone any ideas? Seems like a bug to me.

  • Comment author was deleted

    Feb 06, 2012 @ 09:21

    Hey Dominic,

    It's not a bug, first option is empty to avoid having a value selected by default

  • Dominic Kelly 114 posts 133 karma points
    Feb 06, 2012 @ 09:46
    Dominic Kelly
    0

    This is very non standard. Usually 'Please select' or similiar is the first option? Usually we will validate properly? This looks untidy.

  • Dominic Kelly 114 posts 133 karma points
    Feb 06, 2012 @ 10:01
    Dominic Kelly
    0
  • Comment author was deleted

    Feb 06, 2012 @ 11:21

    Hi Dominic,

    Well you can still make the property mandatory so if the user doesn't select an option you will be able to provide some validation text

    As an alternative you could create a custom dropdown type that does have an filled first value instead of an empty one

  • Dominic Kelly 114 posts 133 karma points
    Feb 06, 2012 @ 11:31
    Dominic Kelly
    0

    In my opinion, this is an extremely poor design decision. I've never seen drodowns done this way. 

    • Please select
    • Option 1
    • Option 2
    Is about as universal as it gets.
    • Please select
    • Option 1
    • Option 2
    Is weird and untidy.
    I'm not creating a custom field type to get rid of an empty field, that's completely unesseary for what is supposed to be a plug and play extension. I've already had to create a seperate database table to store 3 email addresses!
  • Steve 472 posts 1216 karma points
    Nov 13, 2012 @ 15:16
    Steve
    0

    Dominic, How would you even create a custom dropddown type? You can't see any xslt for the forms you create.

  • Liam Dilley 153 posts 379 karma points
    Jul 16, 2020 @ 00:37
    Liam Dilley
    1

    2012 Thread but one that shows up high in google searches on this topic. I like to put answers for the next person that comes along...

    Either in your theme Fieldtypes overide folder or the default forms theme.. In: FieldType.DropDownList.cshtml

    You want to add:

    @{
    var settings = Model.AdditionalSettings;
    }
    

    And then you want to replace:

    <option value=""></option>
    

    With:

    <option value="">@settings["DefaultValue"]</option>
    

    Then you can use the default value field on the property in the admin to populate and the value still is 0.

Please Sign in or register to post replies

Write your reply to:

Draft