How do i get the value of a checkbox from another form/page and how do i make it so if the checkbox is enabled, it’ll allow a button to be visible?
checkbox in SettingsForm.php:
$form['#tree'] = TRUE; $form['clients_enabled'] = array( '#title' => t('Enable PixelPin OpenID Connect'), '#type' => 'checkboxes', '#options' => array('pixelpin' => $this->t('Enable')), '#default_value' => $clients_enabled, );
button ion LoginForm.php:
public function buildForm(array $form, FormStateInterface $form_state) { $definitions = $this->pluginManager->getDefinitions(); foreach ($definitions as $client_id => $client) { foreach ($this->pluginManager->getDefinitions() as $client_name => $client_plugin) { if (!$this->config('pixelpin_openid_connect.settings.' . $client_id) ->get('enabled')) { $url = Drupal::service('path.current')->getPath(); $find = 'login'; $pos = strpos($url, $find); if ($pos === false){ $value = 'Register Using @client_title'; } else { $value = 'Log in with @client_title'; } $element = 'clients_enabled[' . $client_plugin['id'] . ']'; $form['pixelpin_openid_connect_client_' . $client_id . '_login'] = array( '#type' => 'submit', '#value' => t($value, array( '@client_title' => $client['label'], )), 'visible' => array( ':input[name="' . $element . '"]' => array('checked' => TRUE), ), '#name' => $client_id, '#prefix' => '<div>', '#suffix' => '</div>', ); } } } return $form;
Sponsored by SupremePR