$form['questionfield_form_fieldset'][$i]['answer_type'] = [
'#type' => 'radios',
'#title' => $this->t('Select Answer Type'),
'#options' => array(
'select' =>t('Drop Down'),
'radios' =>t('Radio'),
'rating' =>t('Rating'),
),
'#description' => $this->t('Select the way answer will disply eg. in radio button or in selectbox(Dropdown)'),
'#default_value' => $config->get($form_count . '.' . $drupal_form_id . '.' . 'answer_type'),
'#required' => TRUE,
];
$form['questionfield_form_fieldset'][$i]['answer_box_id'] = [
'#type' => 'textarea',
'#title' => $this->t('Answer for above question'),
'#description' => $this->t('Add your answers for above question here.'),
'#default_value' => $config->get($form_count . '.' . $drupal_form_id . '.' . 'answer_box_id'),
'#required' => TRUE,
'#states' => array(
'visible' => array(
array(
array(":input[name='questionfield_form_fieldset[$i][answer_type]']" => array('value' => 'select')),
'or',
array(":input[name='questionfield_form_fieldset[$i][answer_type]']" => array('value' => 'radios')),
),
),
),
];
I want to make answer_box_id as not required when user click rating radio button .