I am trying to use checkboxes to display inline entity form elements only when the boxes are checked. However, my code doesn't seem to be working. It will hide the element, but when I toggle the checkbox, it won't display what was hidden.
Here is my code:
function lodestar_form_user_profile_form_alter(&$form, &$form_state) {
dpm($form);
$form['field_your_nonprofit_connections']['und'] = array(
'#states' => array(
'visible' => array(
':input[name="field_affiliation_type[und][#options]"]' => array('value' => 'Nonprofit'),
),
),
);
}
Here is a screenshot of the field_your_nonprofit_connections field:
And here is one for the field_affiliation_type field:
Based on what I have been reading in this related question (When using hook_form_alter to modify a content type's node add / edit form, where do I put the #states property?), I have now realized that my form is not even including the #states element at all.
How do I add the #states element into an already existing form via hook_form_alter?
And, how do I get the checkbox field to toggle the visibility?