1

We need to make the term reference field select list to have no options because the vocabulary have big number of terms which makes the form loads very slow due to getting the term list from DB and render them.

That field is being updated by ajax so we need it start clean with no DB operation to increase performance and page loads fast.

Implementing: hook_field_attach_form or hook_form_alter

has no effect as we see the form is built.

what we need i to prevent DB reading list.

if($form_id == 'field_ui_field_edit_form'){
      $form['instance']['default_value_widget']['field_brand']['und']['#options'] = array(0 => t('No'));
} 

Above code didn't change any thing in node/add form which still list all brands

Is it posible in drupal?

| improve this question | | | | |
  • did you used devel ?? – Adi Oct 16 '15 at 5:48
  • devel for what, I could print the form array and see what inide – Mohammed Gomma Oct 16 '15 at 15:00
0

Try with the following code

function yourmodule_form_alter(&$form, &$form_state, $form_id){
 if($form_id == 'your-edit-form-id'){
   $form['your-select-feild']['#options'] = array();
 }
}

Hope this will help you..

| improve this answer | | | | |
  • I don't need resetting the options I need to set to null, if you checked the options you will find it filled – Mohammed Gomma Oct 16 '15 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.