I've created a subtheme based on mothership (7.x-1.12). I've enabled the Feeds module and configured an importer to import a CSV file and create some nodes through a standalone form. When I visit the import/% page the form shows, except for the file selection field:

What happens is that on line 98 in the mothership_form_elements($variables) function (file form.php), a check is made to see if there's a title. If not, the display_title setting is set to none:

// If #title is not set, we don't display any label or required marker.
  if (!isset($element['#title'])) {
    $element['#title_display'] = 'none';
  }

On line 105 a switch statement is used:

  switch ($element['#title_display']) {

On line 153 and onwards the field is written to the output:

   case 'none':
    case 'attribute':
      // Output no label and no required marker, only the children.
      $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n";
      break;

The file upload field is in the $element['#description'] variable, which is left out in the cases 'none' and 'attribute'.

I see no immediate fix other than changing the test for element('#title') to include a check for file fields.

CommentFileSizeAuthor
missing_fileuploadelement.png24.12 KBGerben Spil
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mortendk’s picture

Assigned: Unassigned » mortendk
Gerben Spil’s picture

// If #title is not set, we don't display any label or required marker.
  if (!isset($element['#title'])) {
    $element['#title_display'] = 'none';
  }

Could be made into:

// If #title is not set, we don't display any label or required marker.
  if (!isset($element['#title']) && $element['#type'] != 'file') {
    $element['#title_display'] = 'none';
  }
AaronELBorg’s picture

Yeah, using theme_form_element (which I'm assuming Mothership does) gets really confusing.

Note: I'm not using Mothership.......I just found this thread doing a google search.

Since I don't have tons of time to spend trying to fix the issue. (I just want a friggin' "upload" button!!)

....I did this after the switch statement.

<?php
if ($element['#type'] == 'file'){
      echo $element['#description'];
    }
?>

Gets the button back anyway.

I have a feeling that this in theme_form_element is causing something odd with the Feeds module:

<?php

$element += array(
    '#title_display' => 'before',
  );
?>

I'm fully aware that I could be wrong, however.

AaronELBorg’s picture

Ok, ok....

Lemme put down the crack pipe for a sec (I kid, amigos. I kid.)

That dirty hack in #3 comes with its own fair share of problems and could be a bit less dirty by simply appending all this stuff into $output.

Put it right after the closing tag of the switch statement.

<?php
if ($element['#type'] == 'file'){
      $output .= $element['#description'];
    }
?>