Create Advanced Custom Field

<div class="group-input-fields-content" data-callback-render="render_my_custom_slider">
<div class="form-group">
<div class="input-group">
<input data-dimension="<%= field.options[:dimension] %>" data-versions="<%= field.options[:versions] %>" data-thumb_size="<%= field.options[:thumb_size] %>" type="url" name="<%= field_name %>[<%= field.slug %>][values][][image]" class="data-error-place-parent image_field form-control <%= "required" if field.options[:required].to_s.to_bool %>"/>
<span class="input-group-addon btn_upload" onclick="load_upload_image_field($(this).prev());"><i class="fa fa-upload"></i> <%= t('camaleon_cms.admin.button.upload_image')%> <%= "(#{field.get_option('dimension')})" if field.get_option('dimension').present? %></span>
<div class="clearfix">
<div class="form-group">
<label>Title: </label>
<input placeholder="Title" type="text" name="<%= field_name %>[<%= field.slug %>][values][][title]" class="title_field translatable form-control required"/>
<div class="form-group">
<label>Description: </label>
<textarea placeholder="Description" name="<%= field_name %>[<%= field.slug %>][values][][descr]" class="descr_field form-control translatable required"></textarea>
function render_my_custom_slider(panel, values){
values = values || {};
values = typeof(values) == 'string' ? $.parseJSON(values) : values;

// config/config.json
"hooks": {
"extra_custom_fields": ["eshop_extra_custom_fields"]

# /themes/e_shop/main_helper.rb
module Themes::EShop::MainHelper
def eshop_extra_custom_fields(args)
args[:fields][:my_slider] = {
key: 'my_slider',
label: 'My Slider',
render: theme_view('custom_field/my_slider.html.erb'),
options: {
required: true,
multiple: true,
type: 'text_box',
key: 'dimension',
label: 'Dimensions',
description: 'Crop images with dimension (widthxheight), sample:<br>400x300 | 400x | x300 | ?400x?500 | ?1400x (? => maximum, empty => auto)'

To use in your code to render your slider code:

# for single group
# will return array of values like [{"image"=>"http://localhost:30...9.png", "title"=>"ddfdfg", "descr"=>"dfgdfgdfg"}]

# For multiple groups, you can use this:
myobject.the_fields_grouped(['test-slider'], true)
# will return like: [{"test-slider"=>[{"image"=>"http:...testimg.jpg", "title"=>"test slide 1", "descr"=>"descr slide 1"}]}, {"test-slider"=>[{"image"=>"http:.._ban.jpg", "title"=>"test slide 2", "descr"=>"sadasda2"}]}]

Sample to use as shortcode:

  1. Create front template (attrs received: {object, field, field_key, attibutes})
    <% slides = object.the_field_grouped(field_key, true) %>
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
    <% slides.each_with_index do |i, index| %>
    <li data-target="#carousel-example-generic" data-slide-to="<%= index + 1 %>" class="><%= 'active' if index == 0 %>"></li>
    <% end %>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
    <% slides.each_with_index do |item, index| %>
    <div class="item <%= 'active' if index == 0 %>">
    <img src="<%= item[:image] %>" alt="...">
    <div class="carousel-caption">
    <%= item[:title] %>
    <% end %>

    <!-- Controls -->
    <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
    <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  2. Edit your content and add like this:
    This is a sample for shortcode in content editor: ]data field='test-slider' render_field='true']. Note: 'test-slider' is the key of the custom field assigned
  3. Go to view your page and you will see rendered shorcode

    Sample source code: