Last active
November 13, 2016 14:18
-
-
Save owen2345/b9cb0437b338ac712be59f6a7a7ebf70 to your computer and use it in GitHub Desktop.
Camaleon CMS Create Own Custom Fields (Simple Country Select)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/themes/e_shop/views/custom_field/_country_select.html.erb | |
<div class="group-input-fields-content"> | |
<%= select_tag "#{field_name}[#{field.slug}][values][]", options_for_select(ISO3166::Country.all_names_with_codes), class: "form-control input-value #{"required" if field.options[:required].to_s.to_bool}" %> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /themes/e_shop/config/config.json | |
{ | |
... | |
... | |
"hooks": { | |
"extra_custom_fields": ["eshop_extra_custom_fields"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/themes/e_shop/config/Gemfile | |
gem 'country_select' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/themes/e_shop/main_helper.rb | |
module Themes::EShop::MainHelper | |
def eshop_extra_custom_fields(args) | |
args[:fields][:my_country_select] = { | |
key: 'my_country_select', | |
label: 'Country Selector', | |
render: theme_view('custom_field/country_select.html.erb'), | |
options: { | |
required: true, | |
multiple: true, | |
} | |
} | |
end | |
end |
It is not work in https://github.com/owen2345/camaleon-cms/tree/master/spec/dummy, but work in standlone rails appliation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result: