diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs
index 464a201b..563ab716 100644
--- a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs
@@ -98,6 +98,19 @@
class="small"}}
+
+
+
+
+
+
+
+ {{i18n 'admin.wizard.field.char_counter_placeholder'}}
+ {{input
+ type="checkbox"
+ checked=field.char_counter}}
+
+
{{/if}}
{{#if isUpload}}
diff --git a/assets/javascripts/wizard/templates/components/wizard-field.hbs b/assets/javascripts/wizard/templates/components/wizard-field.hbs
index 3a75c200..86e209c2 100644
--- a/assets/javascripts/wizard/templates/components/wizard-field.hbs
+++ b/assets/javascripts/wizard/templates/components/wizard-field.hbs
@@ -16,8 +16,10 @@
{{/if}}
-{{#if textType}}
- {{char-counter field.value}}
+{{#if field.char_counter}}
+ {{#if textType}}
+ {{char-counter field.value}}
+ {{/if}}
{{/if}}
{{#if field.errorDescription}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index de60aca9..fef9c870 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -166,6 +166,8 @@ en:
min_length_placeholder: "Minimum length in characters"
max_length: "Max Length"
max_length_placeholder: "Maximum length in characters"
+ char_counter: "Character Counter"
+ char_counter_placeholder: "Display Character Counter"
file_types: "File Types"
limit: "Limit"
property: "Property"
diff --git a/controllers/custom_wizard/admin/wizard.rb b/controllers/custom_wizard/admin/wizard.rb
index a9a01035..9859f115 100644
--- a/controllers/custom_wizard/admin/wizard.rb
+++ b/controllers/custom_wizard/admin/wizard.rb
@@ -98,6 +98,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
:type,
:min_length,
:max_length,
+ :char_counter,
:file_types,
:format,
:limit,
diff --git a/extensions/wizard_field.rb b/extensions/wizard_field.rb
index 9fd8d6d1..49744fa7 100644
--- a/extensions/wizard_field.rb
+++ b/extensions/wizard_field.rb
@@ -6,6 +6,7 @@ module CustomWizardFieldExtension
:key,
:min_length,
:max_length,
+ :char_counter,
:file_types,
:format,
:limit,
@@ -20,6 +21,7 @@ module CustomWizardFieldExtension
@key = attrs[:key]
@min_length = attrs[:min_length]
@max_length = attrs[:max_length]
+ @char_counter = attrs[:char_counter]
@file_types = attrs[:file_types]
@format = attrs[:format]
@limit = attrs[:limit]
diff --git a/lib/custom_wizard/builder.rb b/lib/custom_wizard/builder.rb
index d7d5a517..035490a6 100644
--- a/lib/custom_wizard/builder.rb
+++ b/lib/custom_wizard/builder.rb
@@ -159,6 +159,7 @@ class CustomWizard::Builder
params[:key] = field_template['key'] if field_template['key']
params[:min_length] = field_template['min_length'] if field_template['min_length']
params[:max_length] = field_template['max_length'] if field_template['max_length']
+ params[:char_counter] = field_template['char_counter'] if field_template['char_counter']
params[:value] = prefill_field(field_template, step_template)
if !build_opts[:reset] && (submission = @wizard.current_submission)
diff --git a/lib/custom_wizard/field.rb b/lib/custom_wizard/field.rb
index 53a8b5da..0c19b321 100644
--- a/lib/custom_wizard/field.rb
+++ b/lib/custom_wizard/field.rb
@@ -4,16 +4,19 @@ class CustomWizard::Field
text: {
min_length: nil,
max_length: nil,
- prefill: nil
+ prefill: nil,
+ char_counter: nil
},
textarea: {
min_length: nil,
max_length: nil,
- prefill: nil
+ prefill: nil,
+ char_counter: nil
},
composer: {
min_length: nil,
max_length: nil,
+ char_counter: nil
},
text_only: {},
date: {
diff --git a/serializers/custom_wizard/wizard_field_serializer.rb b/serializers/custom_wizard/wizard_field_serializer.rb
index c331dda2..829a7fa9 100644
--- a/serializers/custom_wizard/wizard_field_serializer.rb
+++ b/serializers/custom_wizard/wizard_field_serializer.rb
@@ -7,7 +7,8 @@ class CustomWizard::FieldSerializer < ::WizardFieldSerializer
:format,
:limit,
:property,
- :content
+ :content,
+ :char_counter
def label
return object.label if object.label.present?
@@ -54,4 +55,8 @@ class CustomWizard::FieldSerializer < ::WizardFieldSerializer
def include_choices?
object.choices.present?
end
+
+ def char_counter
+ object.char_counter
+ end
end
\ No newline at end of file