Module: ActionView::Helpers::FormOptionsHelper
- Defined in:
- lib/english_county_select.rb
Constant Summary collapse
- COUNTIES =
All the counties included in the english_county_options output.
[ ["England", [ "Avon", "Bedfordshire", "Berkshire", "Borders", "Bristol", "Buckinghamshire", "Cambridgeshire", "Channel Islands", "Cheshire", "Cleveland", "Cornwall", "Cumbria", "Derbyshire", "Devon", "Dorset", "Durham", "East Riding of Yorkshire", "East Sussex", "Essex", "Gloucestershire", "Greater Manchester", "Hampshire", "Herefordshire", "Hertfordshire", "Humberside", "Isle of Man", "Isle of Wight", "Isles of Scilly", "Kent", "Lancashire", "Leicestershire", "Lincolnshire", "London", "Merseyside", "Middlesex", "Norfolk", "North Yorkshire", "Northamptonshire", "Northumberland", "Nottinghamshire", "Oxfordshire", "Rutland", "Shropshire", "Somerset", "South Yorkshire", "Staffordshire", "Suffolk", "Surrey", "Tyne and Wear", "Warwickshire", "West Midlands", "West Sussex", "West Yorkshire", "Wiltshire", "Worcestershire" ] ], ["Wales", [ "Blaenau Gwent", "Bridgend", "Caerphilly", "Cardiff", "Ceredigion", "Conwy", "Denbighshire", "Flintshire", "Gwynedd", "Isle of Anglesey", "Merthyr Tydfil", "Monmouthshire", "Neath Port Talbot", "Newport", "Pembrokeshire", "Powys", "Rhondda Cynon Taff", "Swansea", "The Vale of Glamorgan", "Torfaen", "Wrexham" ] ], ["Scotland", [ "Aberdeen City", "Aberdeenshire", "Angus", "Argyll and Bute", "Armagh", "Carmarthenshire", "Clackmannan", "Dumfries and Galloway", "East Ayrshire", "East Dunbartonshire", "East Lothian", "East Renfrewshire", "Edinburgh City", "Falkirk", "Fife", "Glasgow", "Highland", "Inverclyde", "Midlothian", "Moray", "North Ayrshire", "North Lanarkshire", "Orkney", "Perthshire and Kinross", "Renfrewshire", "Roxburghshire", "Shetland", "South Ayrshire", "South Lanarkshire", "Stirling", "West Dunbartonshire", "West Lothian", "Western Isles" ] ], ["Northern Ireland", [ "Antrim", "Down", "Fermanagh", "Londonderry", "Tyrone" ] ] ]
Instance Method Summary collapse
-
#english_county_options_for_select(selected = nil, priority_counties = nil) ⇒ Object
Returns a string of option tags for pretty much any english_county in the world.
-
#english_county_select(object, method, priority_counties = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using english_county_options_for_select to generate the list of option tags.
Instance Method Details
#english_county_options_for_select(selected = nil, priority_counties = nil) ⇒ Object
Returns a string of option tags for pretty much any english_county in the world. Supply a english_county name as selected
to have it marked as the selected option tag. You can also supply an array of counties as priority_counties
, so that they will be listed above the rest of the (long) list.
NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/english_county_select.rb', line 14 def (selected = nil, priority_counties = nil) = "" if priority_counties += (priority_counties, selected) += "<option value=\"\" disabled=\"disabled\">-------------</option>\n" selected=nil if priority_counties.include?(selected) end return ( + (COUNTIES, selected)).html_safe end |
#english_county_select(object, method, priority_counties = nil, options = {}, html_options = {}) ⇒ Object
Return select and option tags for the given object and method, using english_county_options_for_select to generate the list of option tags.
6 7 8 |
# File 'lib/english_county_select.rb', line 6 def english_county_select(object, method, priority_counties = nil, = {}, = {}) InstanceTag.new(object, method, self, .delete(:object)).to_english_county_select_tag(priority_counties, , ) end |