I am using the following code.

public function buildForm(array $form, FormStateInterface $form_state) {
 $appDir = take_control_app_dir();
 $extpath = take_control_fb_ext_client_path();

 $validationString = take_control_random_string(20);
 $fbpath = take_control_client_path(drupal_get_path('module', 'fb') . '/fb.html?extpath=' . $extpath);
 $form = [
   'example one' => [
     '#markup' => '<iframe src="www.google.com"></iframe>'
   'take_control' => [
     '#markup' => '<p>iframe</p>',     

 return $form;

The <iframe> tag is not rendered.

Is there any way to make it render?

1 Answer 1


Probably iframe is filtered in #markup. Use an inline_template instead:

  'example one' => [
    '#type' => 'inline_template',
    '#template' => '<iframe src="{{ url }}"></iframe>',
    '#context' => [
      'url' => 'www.google.com',
  • As of Drupal 10.1.x there is now an iframe render element. drupal.org/node/3264760
    – imclean
    Mar 16 at 2:50
  • Am I interpreting this correctly that this new render element does only support #width as number in pixels, but no percentages like '#width' => '100%' ?
    – Hudri
    Mar 16 at 8:10
  • @Hudri, these are just attributes for the HTML iframe tag, so this is not Drupal-specific. But there is another problem. I couldn't find it in the 10.1.x codebase, this was never submitted. I roll back the answer.
    – 4uk4
    Mar 16 at 8:52

Your Answer

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

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