I'm still pretty new to Drupal and had a question about the node-edit-form twig template. In them template, you can render {{form}}, {{form.advanced}}, and {{form.actions}} but when using xdebug, the form variable doesn't actually have those values in the array. How are those being processed? I'm curious now i'f I've missed this in other twig templates for other arrays/objects.

2 Answers 2


When you xdebug $variables in a preprocess hook

function mymodule/mytheme_preprocess_node_edit_form(&$variables) {


you find $variables['form']['actions'] and the other form elements. You can also install a module to set a breakpoint in the twig template directly, see https://www.drupal.org/docs/8/theming/twig/debugging-twig-templates

What you now have is probably the form build $form in a different place.

  • That's certainly how I've handled everything else ( I have both xdebug running in my environment and devel for breakpoints in twig templates ), however, in this specific case there isn't actually an 'actions' or 'advanced' property in the $vars['form'] array. the only properties on the form array that aren't render array properties ( like $variables['form']['#something']) are $variables['form']['meta'] and $variables['form']['menu'] properties. Does the form check the form_state before the form itself and compiles based on that?
    – ovp
    Commented Feb 7, 2019 at 19:11
  • 1
    I see 23 top level form elements + 28 #-properties in $variables['form'] when I stop in the preprocess hook . What do you mean by "in this specific case", what is specific? - To your last question, a form can be built based on $form_state. For a normal form it is rather empty on the first form build, so it's more about rebuilding the form depending on user input, but especially in an entity form it contains already the entity object prefilled with default values.
    – 4uk4
    Commented Feb 7, 2019 at 20:57
  • Wow... I didn't even think about it until you mentioned it but I have a similar number of total array elements but I can only see ~30 of them in the debugger output in vscode. I found this thread stackoverflow.com/questions/49752153/… that fixed the issue. Thanks for your help!
    – ovp
    Commented Feb 11, 2019 at 15:07

VSCode by default sets a limit at ~32 max elements to display in an array so it was truncating the rest. I followed the advice in this post to fix the issue -- which was simply adding the xdebugSettings to the launch.json file in vscode.

            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "xdebugSettings": {
                "max_children": 999,

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.