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


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


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;



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.