%#
The following params are the variables that can be used in this partial.
@param form [Wallaby::FormBuilder] custom form object that adds a few helper methods and delegate missing methods to the view
@param object [Wallaby::ResourceDecorator] decorator instance which wraps the resource (e.g. ActiveRecord) instance
@param field_name [String] name of the field
@param value [Object] value of the field
@param metadata [Hash] metadata of the field
%>
<% form_value = value.is_a?(String) ? value : (JSON.pretty_generate(value) rescue nil) %>
<%= form.label field_name, metadata[:label] %>
<%= form.text_area field_name, value: form_value, class: 'form-control', data: { init: 'codemirror', mode: 'javascript' } %>
<%= form.error_messages field_name %>
<%= hint_of metadata %>
<% unless @codemirror_init %>
<% @codemirror_init = true %>
<% content_for :custom_javascript do %>
<% javascript_tag do %>
documentReady('.codemirror_init', function () {
$('textarea[data-init="codemirror"]').each(function (index, element) {
CodeMirror.fromTextArea(element, {
mode: $(element).data('mode')
});
})
})
<% end %>
<% end %>
<% end %>