Creating conditional fields: How should I implement hook_form_alter()? Backstory: I used and highly enjoyed Conditional Fields modules for D6 in the past. Currently using 7.x-3.x-dev. But had some issues recently with it and would rather just learn how to do it manually. Familiar with Devel, but had no luck successfully getting a complex hook_form_alter() to work. Always end up hitting a dead-end. 

What are the fundamentals of implementing a hook_form_alter()? 

I'd like to get this process laid out and in one single location. Thanks.
The Conditional Fields module's features can be done with using #states attribute from form api in D7.

If you want to implement it, of course you need to use hook_form_alter() to bring additionaly attributes on existing fields. There many tutorials about the usage of hook_form_alter().

Example of using of #states attribute:

  $form['student_type'] = array(
    '#type' =&gt; 'radios',
    '#options' =&gt; array(
      'high_school'   =&gt; t('High School'),
      'undergraduate' =&gt; t('Undergraduate'),
      'graduate'      =&gt; t('Graduate'),
    ),
    '#title' =&gt; t('What type of student are you?')
  );
  $form['high_school'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('High School Information'),
    // This #states rule says that the "high school" fieldset should only
    // be shown if the "student_type" form element is set to "High School".
    '#states' =&gt; array(
      'visible' =&gt; array(
        ':input[name="student_type"]' =&gt; array('value' =&gt; 'high_school'),
      ),
    ),
  );


Example from Examples for Developers module - form_example module