I have a form in which I am providing some options to users. But I want the options to appear in the form on the basis of presence of 3rd party libraries in vendor directory. I want something like this:
public function buildForm(array $form, FormStateInterface $form_state) {
$form['settings']['tools'] = array(
'#type' => 'radios',
'#title' => $this->t('tools'),
'#options' => array(),
'#default_value' => $this->config('module.settings')->get('tools'),
);
if(check_whether_xyz_library_is present_in_vendor_folder) {
$form['settings']['tools']['#options'] = array('xyz' => 'xyz');
}
The vendor folder is present in the module directory itself and I am using composer to download third party dependencies. Since I do not want to check this during installation of module but during form rendering then I suppose hook_requirements is not option. Any ideas on how to do so?