Is there any way to disable the field 'model_article_nr' until 'model' is selected
this is what i have and as it is now i can select 'model_article_nr' before i have choosen a model which leads to wrong article nummer if i change model afterwords, because when no model is selected the first model is standard in my '$article_list[$curent_model]' and beeing displayed as options in 'model_article_number'
$model_list = array();
$article_list = get_model_article_list();
foreach($article_list as $key => $value) {
if ( empty($curent_model) ) $curent_model = $key;
$model_list[$key] = $key;
}
$form['model'] = array(
'#type' => 'select',
'#title' => t('Model'),
'#title_display' => 'invisible',
'#empty_option' => t('Select Model'),
'#options' => $model_list,
'#ajax' => array(
'callback' => 'form_model_callback',
'wrapper' => 'article-number-ajax-wrapper',
),
'#prefix' => '<div class="clearfix"></div><div class="form-helper-container">',
'#suffix' => '<button type="button" class="btn tooltip-btn" data-toggle="modal" data-target="#model-help"><span class="glyphicon glyphicon-question-sign"></span></button></div>',
);
$form['model_article_nr'] = array(
'#type' => 'select',
'#title' => t('Article Number'),
'#title_display' => 'invisible',
'#attributes' => array('placeholder' => t('Article Number'), 'class' => array('space-bottom')),
'#empty_option' => t('Select Article Number'),
'#validated' => TRUE,
'#options' => $article_list[$curent_model],
'#prefix' => "<div id='article-number-ajax-wrapper'>",
'#suffix' => "</div>",
);
And my callback
function form_model_callback($form, &$form_state) {
return $form['model_article_nr'];
}
#states
, see lullabot.com/articles/form-api-states