It should be very straightforward and yet, I can’t identify the reason why this doesn’t add a placeholder to a field in a form:
function posts_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ($form_id == "node_post_form" || $form_id == "node_post_edit_form") { $form['field_post_subject']['#attributes']['placeholder'] = t("blah"); dpm($form['field_post_subject']); } }
This confirms that the key placeholder
is being set:
The hook_form_alter() works as expected for other things I need to change, except the placeholder. I looked everywhere and it’s always the same solution so I’m wondering what I’m missing?