1

I am planning to create a field type to use as hidden captcha: a field that is hidden to users using a browser with enabled CSS, used to verify if the user registration is not done by a human being. I though to derive its widget from the StringTextAreaWidget class, but I noticed that StringTextareaWidget::formElement() uses two CSS classes: js-text-full and text-full.

What do those CSS classes do?

I would like the widget to be very similar to the textarea used to enter a long string, except that a CSS class I add would make it invisible. I would not want that the existing CSS classes would interfere in some way.

Alternatively, is there another class I should use? I see there is a TextareaWidget class, but it seems for text with an input format associated, while I would need just plain text, without any input format associated.

2 Answers 2

2

These are classes that Drupal sets for its own css and js. For javascript it is always with the prefix "js". At first sight this seems to be redundant. The reason is, if someone wants to override the css class, it doesn't effect the js behavior and vice versa.

If you want to address the field through your own css, you can always target the field name "edit-mytextfield". If you use a class with the name of a text format, there is a chance, that you target other fields you don't want.

1

I'm assuming that full means that the text are widget uses the full text format.

According to the drupal 8 standard classes that are used by JavaScript to select elements should start with the js prefix. That way the themers will know not to remove them.

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.