Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Tag Helpers: <option/> tag helper #1423

Closed
dougbu opened this issue Oct 21, 2014 · 1 comment
Closed

Tag Helpers: <option/> tag helper #1423

dougbu opened this issue Oct 21, 2014 · 1 comment

Comments

@dougbu
Copy link
Member

dougbu commented Oct 21, 2014

Current <select/> tag helper only sets selected attributes for <option/> elements generated from the items enumeration. Should support adding this attribute to <option/> elements users provide. E.g. f the Razor source contains

<select for="YearsEmployeed">
  <option value="">Why didn't you select anything?</option>
  <option value="0">Less than 1</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
</select>

the generated code should select the <option value="1"> element when Model.YearsEmployed is 1.


As an added bonus, could perform no automatic selection if the user explicitly provides a selected attribute on one of their options. E.g. if the Razor source contains

<select for="YearsEmployeed" items="SelectList">
  <option value="">Why didn't you select anything?</option>
  <option value="0">Less than 1</option>
  <option value="1">1</option>
  <option value="2" selected="selected">2</option>
  <option value="3">3</option>
</select>

the generated code should include only a single selected attribute even if SelectList contains a SelectListItem for 4 and that's the current Model.YearsEmployed value.
If we decide to support this enhancement, it may need to be tracked as a separate issue.

@danroth27 danroth27 added this to the 6.0.0-beta2 milestone Oct 21, 2014
@dougbu dougbu self-assigned this Oct 29, 2014
dougbu added a commit that referenced this issue Nov 7, 2014
dougbu added a commit that referenced this issue Nov 7, 2014
@dougbu
Copy link
Member Author

dougbu commented Nov 7, 2014

Commit 2d32420 with support from preceding commits 3d84b52 and 30f25fe.

@dougbu dougbu closed this as completed Nov 7, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants