{"record":{"id":"5e538cb90ef65523","repo":"phacility/phabricator","slug":"view-s-does-not-support-children","errorCode":null,"errorMessage":"View '%s' does not support children.","messagePattern":"View '(.+?)' does not support children\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/view/AphrontView.php","lineNumber":109,"sourceCode":"   */\n  protected function canAppendChild() {\n    return true;\n  }\n\n\n  /**\n   * Append a child to the list of children.\n   *\n   * This method will only work if the view supports children, which is\n   * determined by @{method:canAppendChild}.\n   *\n   * @param  wild   Something renderable.\n   * @return this\n   */\n  final public function appendChild($child) {\n    if (!$this->canAppendChild()) {\n      $class = get_class($this);\n      throw new Exception(\n        pht(\"View '%s' does not support children.\", $class));\n    }\n\n    $this->children[] = $child;\n\n    return $this;\n  }\n\n\n  /**\n   * Produce children for rendering.\n   *\n   * Historically, this method reduced children to a string representation,\n   * but it no longer does.\n   *\n   * @return wild Renderable children.\n   * @task\n   */","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/view/AphrontView.php#L91-L127","documentation":"AphrontView::appendChild() only works on views that accept children, as decided by canAppendChild(). The base class returns true, but structured container views override it to return false — e.g. PHUIListView, PHUICrumbsView, PHUIPropertyListView, PHUITabGroupView and PHUIStatusListView — because their items must be added through typed APIs (addMenuItem(), addCrumb(), addProperty(), addTab()). Appending an arbitrary renderable to such a view throws immediately, at append time rather than render time.","triggerScenarios":"Calling appendChild($child) on a menu list, crumbs bar, property list, tab group, or status list instead of using the typed add*() method, e.g. $list->appendChild($item) on a PHUIListView.","commonSituations":"Treating every PHUI* object as a generic container while assembling custom UI; porting older phutil_tag/div-based markup into view objects; using the wrong component (a structured list where a PHUIBoxView or plain phutil_tag container was intended).","solutions":["Identify the container class named in the message and use its typed API: addMenuItem() for menus, addCrumb() for crumbs, addProperty() for property lists, addTab() for tab groups.","Wrap free-form content in a child-capable container (phutil_tag(), PHUIBoxView) and add that through the typed API.","Only if you own the subclass and genuinely want free-form children, override canAppendChild() to return true — rarely the right design for structured lists."],"exampleFix":"// before\n$list = id(new PHUIListView());\n$list->appendChild($extra); // throws: PHUIListView does not support children\n\n// after\n$list = id(new PHUIListView());\n$list->addMenuItem($extra_item); // PHUIListItemView","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// canAppendChild() is protected, so narrow by known classes:\n// PHUIListView, PHUICrumbsView, PHUIPropertyListView, PHUITabGroupView,\n// PHUIStatusListView all reject children.\nfunction acceptsChildren($view) {\n  $no_children = array(\n    'PHUIListView',\n    'PHUICrumbsView',\n    'PHUIPropertyListView',\n    'PHUITabGroupView',\n    'PHUIStatusListView',\n  );\n  return !in_array(get_class($view), $no_children, true);\n}","tryCatchPattern":"try {\n  $view->appendChild($child);\n} catch (Exception $ex) {\n  // Structured view: does not take free-form children;\n  // render through a generic container instead.\n  $html = phutil_tag('div', array(), array($view, $child));\n}","preventionTips":["Check the class before appending: structured lists take typed add*() calls, not children.","Use phutil_tag()/PHUIBoxView for free-form nesting.","When authoring a structured view, override canAppendChild() to fail fast and document the typed API."],"tags":["php","phabricator","aphrontview","children","view"],"backgroundTag":"view-children-not-supported","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}