ColorBox + Ajax + Drupal form

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

Аватар пользователя biz_murga biz_murga 1 апреля 2013 в 17:14

Привет всем. У меня появилась проблема с валидацией формы в попап меню модуля "Colorbox". Я создал форму, вот код:
unction product_add_uc_cart_menu() {
return array(
'product' => array(
'page callback' => 'drupal_get_form',
'page arguments' => array('product_add_uc_cart'),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
),
);
}

function product_add_uc_cart($form, &$form_state){
global $_REQUEST;
$node = node_load($_REQUEST['nid']);
$form = array();
foreach($node->field_add_features['und'] as $key => $value){
if($value['tid'] == 34){
$form['street_alley'] = array(
'#type' => 'textfield',
'#title' => t('Street/alley'),
'#required' => true,
'#description' => t('Street or alley?'),
'#weight' => 0
);
}
if($value['tid'] == 35){
$form['name_street_alley'] = array(
'#type' => 'textfield',
'#title' => t('Name of street / alley'),
'#required' => true,
'#description' => t('Enter the name of the street and alley'),
'#weight' => 1
);
}
if($value['tid'] == 36){
$form['house_number'] = array(
'#type' => 'textfield',
'#title' => t('House number'),
'#required' => true,
'#description' => t('Enter the number of'),
'#weight' => 2
);
}
if($value['tid'] == 37){
$form['fixing'] = array(
'#type' => 'checkbox',
'#title' => t('+ Set invisible fastenings (12 USD)'),
'#weight' => 3
);
}
}
$form['color'] = array(
'#type' => 'textfield',
'#disabled' => TRUE,
'#title' => t('The selected color:'),
'#weight' => 4
);
$form['node_nid'] = array(
'#type' => 'hidden',
'#value' => $_REQUEST['nid']
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Add to cart and continue'),
'#weight' => 6,
'#id' => 'edit-submit-' . $_REQUEST['nid'],
'#attributes' => array(
'class' => array('node-add-to-cart'),
),
'#ajax' => array(
'callback' => 'product_add_uc_cart_ajax_callback',
'wrapper' => 'my-form-wrapper',
),
);
$form['button'] = array(
'#type' => 'button',
'#value' => t('Make up order'),
'#weight' => 5,

);

$form['#action'] = url('node/'.$_REQUEST['nid']);
return $form;
}
function product_add_uc_cart_ajax_callback($form, $form_state) {
return $form;
}
function product_add_uc_cart_submit($form, &$form_state){
return uc_cart_add_item($form_state['values']['node_nid']);
}
Но когда форму вывожу в попап меню, не правильно введённые поля при submit не выделяются(красным border). Просмотрите код, может я что то натворил. Спасибо большое. Жду советов и наставлений=)

Комментарии