Motivation

Add basic placeholder support to the form api property.

Remaining tasks

This can also be added to the field widget support, but I have not checked that yet.

CommentFileSizeAuthor
placeholder.patch1.34 KBducktape

Comments

ducktape created an issue. See original summary.

tim-diels’s picture

Status: Active » Closed (won't fix)

Could you give an example on where you would need this?

You could easily use the normal placeholder attribute on the form API or the placeholder option on fields within the form display of an entity type.

Example on how to add this using the form API:

$form['my_text_field_with_placeholder'] = [
  '#type' => 'textfield',
  '#title' => $this->t('My text field with placeholder'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
  '#attributes' => [
    'class' => [
      'text-with-placeholder',
    ],
    'placeholder' => 'The placeholder text',
  ],
];

As there are enough standard/default options to facilitate this, I'm going to close this issue. Please feel free to re-open if you think you do need this feature and the standard/default options are not enough.