Приветствую всех.
Нет времени глубоко разбираться в Друпале, но необходимо осмыслить один момент, связанный со свойством текстового поля формы обратной связи.
Имеется, я так понял, рукописный модуль формы обратной связи, работающий с CTools.
Форма появляется в модальном окне. Есть несколько полей, одно из них обязательно для заполнения, необходимо остальные тоже сделать обязательными.
Кусок кода:
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#required' => TRUE,
);
Добавлено свойство '#required' => TRUE, но в форме на сайте изменений не происходит, поле не отмечено значком * и не проходит валидацию. Где что еще нужно поменять, чтобы поле стало однозначно обязательным и валидируемым. Проверил через имеющиеся файлы модуля, в код вписал тестовые слова, но они также не отобразились в форме обратной связи, кеш в браузере после изменений в коде чистил, никаких изменений, такое ощущение, что имеющиеся файлы модуля и сам модуль никак не цепляется системой Друпал. Пробовал переименовывать файлы и папки модуля, но форма после чистки кеша продолжает работать, как будто ничего не переименованно. Появляется ошибка только в том случае, если в админке в разделе модули отключаю данный модуль.
Подскажите, где в каком направлении копать, уже мозг кипит - не думал, что Друпал такой хитрый движок.
Заранее благодарю за помощь.
Привожу код файла wicked_call.module, остальные файлы не привожу - они для модуля стандартны.
<?php
/**
* file
* Sample AJAX functionality so people can see some of the CTools AJAX
* features in use.
*/
function wicked_call_form($form, &$form_state) {
$form = array();
$form['#attributes']['enctype'] = 'multipath/form-data';
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#required' => TRUE, //строка добавлена
);
$form['phone'] = array(
'#type' => 'textfield',
'#title' => t('Телефон'),
'#required' => TRUE,
);
$form['comment'] = array(
'#type' => 'textarea',
'#title' => t('Ваш комментарий и удобное время для звонка'),
'#required' => TRUE, //строка добавлена
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Заказать звонок'),
);
return $form;
}
// ---------------------------------------------------------------------------
// Drupal hooks.
/**
* Implementation of hook_menu()
*/
function wicked_call_menu() {
$items = array();
$items['call/%ctools_js/call_login'] = array(
'page callback' => 'wicked_call_sample_login',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* A modal login callback.
*/
function wicked_call_sample_login($js = NULL) {
// Fall back if $js is not set.
if (!$js) {
return drupal_get_form('wicked_call_form');
}
// Create our own javascript that will be used to theme a modal.
ctools_include('modal');
ctools_include('ajax');
ctools_add_js('ajax-responder');
$form_state = array(
'title' => t('Заказать звонок'),
'ajax' => TRUE,
);
$output = ctools_modal_form_wrapper('wicked_call_form', $form_state);
if (!empty($form_state['executed'])) {
// We'll just overwrite the form output if it was successful.
$output = array();
$output[] = ctools_modal_command_display(t('Ваш запрос отправлен!'), '
');
$output[] = ctools_ajax_command_attr('div.ctools-modal-content','style','height: 200px; background-color:#475266; background-image: url(/sites/all/themes/custom/site/img/smartphone-blue.png); background-repeat: no-repeat; background-position: 65% center;');
$output[] = ctools_ajax_command_attr('div.ctools-modal-content .modal-content','style','min-height: 50px');
$output[] = ctools_ajax_command_attr('div.ctools-modal-content div.popups-title','style','background:#475266; color: white; text-align: center');
$output[] = ctools_ajax_command_attr('div.ctools-modal-content .popups-close','style','background: url(/sites/all/themes/custom/site/img/submit-close-button.png); top: 150px; left: 155px; width: 83px; height: 31px');
$output[] = ctools_ajax_command_attr('div.ctools-modal-content .popups-close a','style',' width: 83px; height: 31px');
$output[] = ctools_ajax_command_attr('div.ctools-modal-content .modal-title','style',' color: white');
}
print ajax_render($output);
exit;
}
/**
* Implements hook_validate()
*/
function wicked_call_form_validate($node, $form) {
}
function wicked_call_form_submit($form, &$form_state) {
$message = NULL;
$message .= 'Имя: ' . $form_state['values']['name'] . "\n";
$message .= 'Телефон: ' . $form_state['values']['phone'] . "\n";
$message .= 'Комментарий и время звонка: ' . $form_state['values']['comment'] . "\n";
$attachment = array();
$mail = new x_mail_call();
$mail->from = "sdfjsh@mail.ru";
$mail->to = variable_get('siteinfo:manager_email', 'sdfjsh@mail.ru');
$mail->subject = "Заказ звонка на сайте";
$mail->message = $message;
foreach($attachment as $key => $value) {
$mail->__attachmentsArray($value, $key);
};
$mail->sendmail();
}?>