managed_file ajax загрузка файлов

Главные вкладки

Аватар пользователя kazuto kazuto 13 ноября 2017 в 6:54

Всем привет! Создал свой модуль, с формой, использовал тип managed_file, так вот из за bootstrap темы не работает ajax, т.к. все нужные классы и элементы удалены в темой...
$form['avatar'] = array(
'#type' => 'managed_file',
'#title' => 'Аватар',
'#description' => 'Выберите файл с расширением jpg, jpeg, png или gif',
'#prefix' => '

',
'#suffix' => '

',
'#upload_location' => 'public://',
'#upload_validators' => array(
'file_validate_is_image' => array(),
'file_validate_extensions' => array('png gif jpg jpeg'),
'file_validate_size' => array(1 * 1024 * 1024),
),
'#default_value' => variable_get('submit_advertisement_myfilefid'),
);

Сталкивался ли кто с этой проблемой? пожалуйста подскажите, что возможно предпринять.

Комментарии

Аватар пользователя kazuto kazuto 14 ноября 2017 в 9:02

Есть функция в bootstrap теме, там вот такой код

<?php
/**
* @file
* Stub file for bootstrap_file_managed_file().
*/

/**
* Returns HTML for a managed file element.
*
* @param array $variables
* An associative array containing:
* - element: A render element representing the file.
*
* @return string
* The constructed HTML.
*
* @see theme_file_managed_file()
*
* @ingroup theme_functions
*/
function bootstrap_file_managed_file($variables) {
$output = '';
$element = $variables['element'];

$attributes = array();
if (isset($element['#id'])) {
$attributes['id'] = $element['#id'];
}
if (!empty($element['#attributes']['class'])) {
$attributes['class'] = (array) $element['#attributes']['class'];
}
$attributes['class'][] = 'form-managed-file';
$attributes['class'][] = 'input-group';

$element['upload_button']['#attributes']['class'][] = 'btn-primary';
$element['upload_button']['#prefix'] = '';
$element['upload_button']['#suffix'] = '
';
$element['remove_button']['#prefix'] = '';
$element['remove_button']['#suffix'] = '
';
$element['remove_button']['#attributes']['class'][] = 'btn-danger';

if (!empty($element['filename'])) {
$element['filename']['#prefix'] = '

';
$element['filename']['#suffix'] = '

';
}

// This wrapper is required to apply JS behaviors and CSS styling.
$output .= '

';

// Immediately render hidden elements before the rest of the output.
// The uploadprogress extension requires that the hidden identifier input
// element appears before the file input element. They must also be siblings
// inside the same parent element.
// @see https://www.drupal.org/node/2155419
foreach (element_children($element) as $child) {
if (isset($element[$child]['#type']) && $element[$child]['#type'] === 'hidden') {
$output .= drupal_render($element[$child]);
}
}

// Render the rest of the element.
$output .= drupal_render_children($element);
$output .= '

';
return $output;
}

вот я не понимаю, что здесь изменить, чтобы снова все заработало...