I have an entity creation form and I have a radio button as a field. Now what I need is, if while adding the entity, if radio button is set, then one more field just below should appear otherwise not.
If looking for a module, you can use the D7 -dev version of conditional_fields
Define dependencies between fields based on their states and values.
Conditional Fields for Drupal 7 is an user interface to the new States API, plus the ability to modify fields appearance and behavior on certain conditions when viewing content.
In this example, I show the UPC field when the specified operation value is chosen in a select box:
// Define available batch operation callbacks $operations = array( 'infinity_batch_sync_products' => 'Import and sync product details', 'infinity_fetch_products' => 'Fetch list of available products', 'infinity_fetch_product' => 'Fetch detail on single product' ); $form['operation'] = array( '#type' => 'select', '#title' => t('Select operation'), '#options' => $operations, '#required' => TRUE, ); $form['upc'] = array( '#type' => 'textfield', '#title' => t('UPC'), '#description' => t('Enter the product UPC code (commerce product SKU)'), '#default_value' => 0, '#size' => 20, '#maxlength' => 20, '#states' => array( 'visible' => array( ':input[name="operation"]' => array('value' => 'infinity_fetch_product'), ), ), );
The "UPC" field only shows when the operation is "infinity_fetch_product"