Score:0

Managed_file with table of uploaded files

lc flag

Adding a file field to a custom node type results in a nice UI with a table appearing for all uploaded files, with a Remove button for each. But simply adding a managed_file to our own forms, eg:

$form['attachments'] = [
  '#type' => 'managed_file',
  '#title' => t('Attachments'),
  '#description' => $descriptions,
  '#upload_validators' => $validators,
  '#upload_location' => $this->get_upload_location(),
  '#multiple' => TRUE,
];

displays another UI that, while functionally equivalent, is less desirable (a list of the files, with a checkbox for each, and one common Remove selected button).

The table comes from template_preprocess_file_widget_multiple() but I find no real way to force my form widget to use this UI, neither by specifying #theme or trying to force the file_generic widget. Which crucial step am I missing?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.