I want to display same line label and fields in drupal 8. But by default it's showing field down and label up.

I'm using suffix and prefix it works. How can I display it without suffix and prefix?

 $form['doc_date'] = array(
'#type' => 'date',
'#required' => TRUE,
'#date_date_format' => 'd-m-Y', 
'#default_value' => (isset($record['doc_date']) && $_GET['num']) ? $d_date:'',
  '#attributes' => array('type'=> 'date', 'min'=> '-180 days', 'max' => date('d-m-Y') ),
  '#prefix' => '<tr><td><table><tr><td class="tdtext_form_cre">Document Date : <span class="mand">*</span><td>',
'#suffix' => '</td></tr></table></td></tr>',

2 Answers 2


According to default field.html.twig file template which is use to render fields, you have to set #label_display => 'inline' and #title => 'Your label' Most of themes render inline label and content when class field--label-inline exist, but it is possible that you remove this css style from your theme.

  • Thanks, I have solve this issues using the table concept field.html.twig making complex for other field . Jun 4, 2018 at 5:26

In the views page, field settings, style settings change HTML element to span.enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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