1

I have to insert in a field (admin/structure/types/manage/article/display) a string of classes to get a button from a text but the "Field Formatter Class" field has a character limit so I can't enter the code which I need to get the result. I did some research but couldn't find the solution.

My Class: btn btn-sm btn-primary stpe-outlinebutton test-util-color-primary test-util-border-primary test-util-hover-background-primary test-util-hover-color-white test-util-hover-border-primary

Any help?

Best Regards

0

1 Answer 1

0

I believe you are using the module Field Formatter Class to have this option for your fields.

The module does not set a maximum value for this field. So I believe it is using a default of 128 chars in core.

128 is a fairly long limit for a class field. But if you want to alter this you can write an alter function in your module like they have done in their module and set the #maxlength property of the field_formatter_class element.

Having said that, the following is a quick hack to get this working for you.

You can open the file field_formatter_class/field_formatter_class.module

and add a line

'#maxlength' => 256,

in the element class array in the alter function in line 44. After modification this will be like the following (view original code)

function field_formatter_class_field_formatter_settings_form_alter(&$settings_form, $context) {
  $display = $context['instance']['display'][$context['view_mode']];
  $settings = $display['settings'];
  $settings_form['field_formatter_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Field Formatter Class'),
    '#maxlength' => 256,
    '#default_value' => $settings['field_formatter_class'],
  );

Do note that this is modifying a contrib module and is generally not a recommended approach. You will have to maintain this patch in a patches folder.

2
  • Thank you very much..
    – kipper
    Commented Nov 22, 2019 at 0:57
  • Hope that solved your problem.
    – anoopjohn
    Commented Nov 22, 2019 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.