How to know from variables tu use them in a custom code I know it's a newbie question, but it's take me a lot of time to find a a small code for a small fonctionality.

for example I wanted to make the address phone field required, I didn't know how to know the arrays keys.

        &lt;?php
/**
 * Implements hook_field_widget_form_alter().
 */
function organize_address_field_widget_form_alter(&amp;$element, $form_state, $context) {
  if(!empty($element['#addressfield'])) {
    $element['country']['#weight'] = 100;
    $element['phone_block']['phone_number']['phone_number']['#required'] = TRUE;

  }
}


I tried devel to find it but without result.

So my question,after finding the good hook, how I can know the variables to use.

Is a general question to help me to learn module development.
May be I'm missing something: I don't understand why you want to programatically make the field required.

Required is not a feature of a field by itself, it is an option you can set on its instance once it's attached to a node, through the admin/structure/types/manage/yourContentType/fields/yourFieldName.