0

Registration content type has a required entity reference field. The widget of this field is a select list, the options are populated with a views entity reference display output. I want to hide(unset) the submit button if the views entity reference display returns no value. I've asked a question here for reference, I'm suggested to post a new question.

1 Answer 1

0

You can do this by using hook form FORM ID alter .

Once hooked in you find the $form item for the drop down list. It'll be somewhere like

$form['field_my_entity_ref']['und']['#options']

So you should be able to make a check on the values in that array and if there are none then make the Submit button disabled . My guess is

if ( count($form['field_my_entity_ref']['und']['#options']) < 1 ) {

   $form['#submit']['#disabled'] == TRUE;
 }

https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7.x/#disabled

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_FORM_ID_alter/7.x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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