Example #1
1
 /**
  * Form element validation handler for 'name' in form_test_validate_form().
  */
 public function validateName(&$element, FormStateInterface $form_state)
 {
     $triggered = FALSE;
     if ($form_state->getValue('name') == 'element_validate') {
         // Alter the form element.
         $element['#value'] = '#value changed by #element_validate';
         // Alter the submitted value in $form_state.
         $form_state->setValueForElement($element, 'value changed by setValueForElement() in #element_validate');
         $triggered = TRUE;
     }
     if ($form_state->getValue('name') == 'element_validate_access') {
         $form_state->set('form_test_name', $form_state->getValue('name'));
         // Alter the form element.
         $element['#access'] = FALSE;
         $triggered = TRUE;
     } elseif ($form_state->has('form_test_name')) {
         // To simplify this test, just take over the element's value into $form_state.
         $form_state->setValueForElement($element, $form_state->get('form_test_name'));
         $triggered = TRUE;
     }
     if ($triggered) {
         // Output the element's value from $form_state.
         drupal_set_message(t('@label value: @value', array('@label' => $element['#title'], '@value' => $form_state->getValue('name'))));
         // Trigger a form validation error to see our changes.
         $form_state->setErrorByName('');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     // Validate video URL.
     if (!UrlHelper::isValid($form_state->getValue('video'), TRUE)) {
         $form_state->setErrorByName('video', $this->t("The video url '%url' is invalid.", array('%url' => $form_state->getValue('video'))));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Process the upload and perform validation. Note: we're using the
     // form value for the $replace parameter.
     if (!$form_state->isValueEmpty('file_subdir')) {
         $destination = 'temporary://' . $form_state->getValue('file_subdir');
         file_prepare_directory($destination, FILE_CREATE_DIRECTORY);
     } else {
         $destination = FALSE;
     }
     // Setup validators.
     $validators = array();
     if ($form_state->getValue('is_image_file')) {
         $validators['file_validate_is_image'] = array();
     }
     if ($form_state->getValue('allow_all_extensions')) {
         $validators['file_validate_extensions'] = array();
     } elseif (!$form_state->isValueEmpty('extensions')) {
         $validators['file_validate_extensions'] = array($form_state->getValue('extensions'));
     }
     $file = file_save_upload('file_test_upload', $validators, $destination, 0, $form_state->getValue('file_test_replace'));
     if ($file) {
         $form_state->setValue('file_test_upload', $file);
         drupal_set_message(t('File @filepath was uploaded.', array('@filepath' => $file->getFileUri())));
         drupal_set_message(t('File name is @filename.', array('@filename' => $file->getFilename())));
         drupal_set_message(t('File MIME type is @mimetype.', array('@mimetype' => $file->getMimeType())));
         drupal_set_message(t('You WIN!'));
     } elseif ($file === FALSE) {
         drupal_set_message(t('Epic upload FAIL!'), 'error');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(OrderInterface $order, array &$form, FormStateInterface $form_state)
 {
     if (!$form_state->isValueEmpty('admin_comment')) {
         $uid = \Drupal::currentUser()->id();
         uc_order_comment_save($form_state->getValue('order_id'), $uid, $form_state->getValue('admin_comment'));
     }
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $html_raw = $this->curl_get($form_state->getValue('url'));
     $pattern = '/<div\\s*?class="k-grid-content">.*?<tbody[^>]*>(.*?)<\\/tbody>/msi';
     if (!preg_match($pattern, $html_raw, $matches)) {
         return;
     }
     $pattern = '/<a\\s*href="\\/codigo-postal-([^"]*)">/msi';
     if (!preg_match_all($pattern, $matches[1], $zipcodes_raw)) {
         return;
     }
     $zipcodes = array();
     foreach ($zipcodes_raw[1] as $zipcode_raw) {
         $zipcodes[$zipcode_raw] = $zipcode_raw;
     }
     ksort($zipcodes);
     // Build Pairs
     $state = $form_state->getValue('state');
     $city = $form_state->getValue('city');
     $zipcodesb = $zipcodes;
     $zipcodes_count = 0;
     foreach ($zipcodes as $zipcode_start) {
         foreach ($zipcodesb as $zipcode_end) {
             // Validate we don't already have it.
             if (\Drupal\zipcoderate\Controller\ZipCodeRateController::getRateNode(63175, 63175, false)) {
                 continue;
             }
             $zipcodes_count++;
             $node = \Drupal\node\Entity\Node::create(['title' => "{$city} {$state} - [{$zipcode_start} - {$zipcode_end}]", 'type' => 'rate', 'field_zipcode_start' => $zipcode_start, 'field_zipcode_end' => $zipcode_end, 'field_state' => $state, 'field_city' => $city]);
             $node->save();
         }
     }
     drupal_set_message(t('@zipcodes_count ZipCodes were Imported', array('@zipcodes_count' => $zipcodes_count)), 'status');
 }
Example #6
0
 /**
  * Ajax callback triggered by checkbox.
  */
 function checkboxCallback($form, FormStateInterface $form_state)
 {
     $response = new AjaxResponse();
     $response->addCommand(new HtmlCommand('#ajax_checkbox_value', (int) $form_state->getValue('checkbox')));
     $response->addCommand(new DataCommand('#ajax_checkbox_value', 'form_state_value_select', (int) $form_state->getValue('checkbox')));
     return $response;
 }
 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     if (!$form_state->hasValue('context')) {
         $form_state->setValue('context', xmlsitemap_get_current_context());
     }
     if ($form_state->hasValue(['context', 'language'])) {
         $language = $form_state->getValue(['context', 'language']);
         if ($language == LanguageInterface::LANGCODE_NOT_SPECIFIED) {
             $form_state->unsetValue(['context', 'language']);
         }
     }
     $context = $form_state->getValue('context');
     $this->entity->context = $context;
     $this->entity->label = $form_state->getValue('label');
     $this->entity->id = xmlsitemap_sitemap_get_context_hash($context);
     try {
         $status = $this->entity->save();
         if ($status == SAVED_NEW) {
             drupal_set_message($this->t('Saved the %label sitemap.', array('%label' => $this->entity->label())));
         } else {
             if ($status == SAVED_UPDATED) {
                 drupal_set_message($this->t('Updated the %label sitemap.', array('%label' => $this->entity->label())));
             }
         }
     } catch (EntityStorageException $ex) {
         drupal_set_message($this->t('There is another sitemap saved with the same context.'), 'error');
     }
     $form_state->setRedirect('xmlsitemap.admin_search');
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $paypal_config = $this->config('uc_paypal.settings');
     $session = \Drupal::service('session');
     $order = Order::load($session->get('cart_order'));
     if (!$form_state->isValueEmpty('shippable')) {
         $quote_option = explode('---', $form_state->getValue(['quotes', 'quote_option']));
         $order->quote['method'] = $quote_option[0];
         $order->quote['accessorials'] = $quote_option[1];
         $method = ShippingQuoteMethod::load($quote_option[0]);
         $label = $method['quote']['accessorials'][$quote_option[1]];
         //      $label = $method->label();
         $quote_option = $form_state->getValue(['quotes', 'quote_option']);
         $order->quote['rate'] = $form_state->getValue(['quotes', $quote_option, 'rate']);
         $result = db_query("SELECT line_item_id FROM {uc_order_line_items} WHERE order_id = :id AND type = :type", [':id' => $order->id(), ':type' => 'shipping']);
         if ($lid = $result->fetchField()) {
             uc_order_update_line_item($lid, $label, $order->quote['rate']);
         } else {
             uc_order_line_item_add($order->id(), 'shipping', $label, $order->quote['rate']);
         }
     }
     if ($paypal_config->get('ec_review_company')) {
         $order->delivery_company = $form_state->getValue('delivery_company');
     }
     if ($paypal_config->get('ec_review_phone')) {
         $order->delivery_phone = $form_state->getValue('delivery_phone');
     }
     if ($paypal_config->get('ec_review_comment')) {
         db_delete('uc_order_comments')->condition('order_id', $order->id())->execute();
         uc_order_comment_save($order->id(), 0, $form_state->getValue('order_comments'), 'order');
     }
     $order->save();
     $form_state->setRedirect('uc_paypal.ec_submit');
 }
Example #9
0
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     if ($form_state->getValue('cosign_allow_anons_on_https') == 0 && $form_state->getValue('cosign_allow_cosign_anons') == 1) {
         $form_state->setErrorByName('cosign_allow_anons_on_https', $this->t("Cosign users cannot browse anonymously if Anonymous users can't. Set Allow Anonymous Users to browse over https to Yes. OR"));
         $form_state->setErrorByName('cosign_allow_cosign_anons', $this->t("Cosign users cannot browse anonymously if Anonymous users can't. Set Allow Cosign Users to browse anonymously to No."));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     module_load_include('inc', 'sociallogin');
     $data = get_authentication($form_state->getValue('api_key'), $form_state->getValue('api_secret'));
     if (isset($data['status']) && $data['status'] != 'status') {
         drupal_set_message($data['message'], $data['status']);
         return FALSE;
     }
     parent::SubmitForm($form, $form_state);
     $this->config('sociallogin.settings')->set('sso_site_name', $form_state->getValue('sso_site_name'))->set('api_key', $form_state->getValue('api_key'))->set('api_secret', $form_state->getValue('api_secret'))->set('username_option', $form_state->getValue('username_option'))->set('login_redirection', $form_state->getValue('login_redirection'))->set('register_redirection', $form_state->getValue('register_redirection'))->set('custom_login_url', $form_state->getValue('custom_login_url'))->set('custom_register_url', $form_state->getValue('custom_register_url'))->set('enable_linking', $form_state->getValue('enable_linking'))->set('linking_text', $form_state->getValue('linking_text'))->save();
     if (count(\Drupal::moduleHandler()->getImplementations('add_extra_sociallogin_config_settings')) > 0) {
         // Call all modules that implement the hook, and let them make changes to $variables.
         $config_data = \Drupal::moduleHandler()->invokeAll('add_extra_sociallogin_config_settings');
     }
     if (isset($config_data) && is_array($config_data)) {
         foreach ($config_data as $key => $value) {
             $this->config('sociallogin.settings')->set($value, $form_state->getValue($value))->save();
         }
     }
     drupal_set_message(t('Social Login settings have been saved.'), 'status');
     //Clear page cache
     foreach (Cache::getBins() as $service_id => $cache_backend) {
         if ($service_id == 'dynamic_page_cache') {
             $cache_backend->deleteAll();
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     drupal_set_message('Settings saved');
     $this->configFactory()->getEditable('itk_instagram_hashtag.settings')->set('itk_instagram_hashtag.client_id', $form_state->getValue('client_id'))->set('itk_instagram_hashtag.resolution', $form_state->getValue('resolution'))->set('itk_instagram_hashtag.sort_by', $form_state->getValue('sort_by'))->set('itk_instagram_hashtag.limit', $form_state->getValue('limit'))->set('itk_instagram_hashtag.enable_caption', $form_state->getValue('enable_caption'))->save();
     // Make sure the new settings are available to the js.
     \Drupal::cache('render')->deleteAll();
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     global $config_directories, $install_state;
     $sync_directory = $form_state->getValue('sync_directory');
     if ($sync_directory != config_get_config_directory(CONFIG_SYNC_DIRECTORY)) {
         $settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) array('value' => $sync_directory, 'required' => TRUE);
         drupal_rewrite_settings($settings);
         $config_directories[CONFIG_SYNC_DIRECTORY] = $sync_directory;
     }
     if ($path = $form_state->getValue('import_tarball')) {
         // Ensure that we have an empty directory if we're going.
         $sync = new FileStorage($sync_directory);
         $sync->deleteAll();
         try {
             $archiver = new ArchiveTar($path, 'gz');
             $files = array();
             foreach ($archiver->listContent() as $file) {
                 $files[] = $file['filename'];
             }
             $archiver->extractList($files, config_get_config_directory(CONFIG_SYNC_DIRECTORY));
             drupal_set_message($this->t('Your configuration files were successfully uploaded, ready for import.'));
         } catch (\Exception $e) {
             drupal_set_message($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', array('@message' => $e->getMessage())), 'error');
         }
         drupal_unlink($path);
     }
     // Change the langcode to the site default langcode provided by the
     // configuration.
     $config_storage = new FileStorage(config_get_config_directory(CONFIG_SYNC_DIRECTORY));
     $install_state['parameters']['langcode'] = $config_storage->read('system.site')['langcode'];
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 public function blockSubmit($form, FormStateInterface $form_state)
 {
     $this->configuration['registration_link'] = $form_state->getValue('registration_link');
     $this->configuration['registration_link_text'] = $form_state->getValue('registration_link_text');
     $this->configuration['sponsorship_link'] = $form_state->getValue('sponsorship_link');
     $this->configuration['sponsorship_link_text'] = $form_state->getValue('sponsorship_link_text');
 }
 /**
  * {@inheritdoc}
  */
 public function blockSubmit($form, FormStateInterface $form_state)
 {
     $this->setConfigurationValue('location_forecast', $form_state->getValue(['location', 'location_forecast']));
     $this->setConfigurationValue('forecast_fields', $form_state->getValue(['forecast_fields']));
     $this->setConfigurationValue('number_of_days', $form_state->getValue(['number_of_days']));
     $this->setConfigurationValue('icon_set', $form_state->getValue(['icon_set']));
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $settings = array('standard' => $form_state->getValue('standard'), 'types' => $form_state->getValue('types'));
     $this->currentBundle->setAssignmentSettings(self::METHOD_ID, $settings)->save();
     $this->setRedirect($form_state);
     drupal_set_message($this->t('Package assignment configuration saved.'));
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function blockSubmit($form, FormStateInterface $form_state)
 {
     $this->configuration['hide_empty'] = $form_state->getValue('hide_empty');
     $this->configuration['show_image'] = $form_state->getValue('show_image');
     $this->configuration['collapsible'] = $form_state->getValue('collapsible');
     $this->configuration['collapsed'] = $form_state->getValue('collapsed');
 }
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $category = $form_state->getValue('category');
     $header_bg = $form_state->getValue('header_bg')[0];
     $fid = $form_state->getValue('header_bg')[0];
     $filename = db_select('file_managed', 'f')->condition('f.fid', $fid, '=')->fields('f', array('filename'))->execute()->fetchField();
     $data = db_select('file_managed', 'f')->condition('f.fid', $fid, '=')->fields('f', array('uri'))->execute()->fetchField();
     $config = $this->config('amazons.settings');
     $AccessKeyId = $config->get('AccessKeyId');
     $SecretAccessKey = $config->get('SecretAccessKey');
     $region = $config->get('region');
     $bucket = $config->get('bucketname');
     $s3Client = new \Aws\S3\S3Client(['version' => 'latest', 'region' => $region, 'credentials' => ['key' => $AccessKeyId, 'secret' => $SecretAccessKey]]);
     //Creating bucket dynamically
     // $result1 = $s3Client->createBucket(array('Bucket' => 'mybucket'));
     //
     // echo "<pre>";
     // print_r($result1);
     // exit;
     //$bucket = 'ncdfiles';
     $key = date('ymdhis') . time() . $filename;
     //$data = 'public://ncdfiles/' . $filename;
     $result = $s3Client->putObject(array('Bucket' => $bucket, 'Key' => $key, 'SourceFile' => $data, 'ACL' => 'public-read'));
     db_insert('amazon_s3_data')->fields(array('cat_name' => $category, 'file_path' => $result['ObjectURL'], 'fid' => $fid))->execute();
     drupal_set_message('File uploaded to AWS server');
     return;
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     $pattern = '/^-?\\d*(\\.\\d*)?$/';
     if (!is_numeric($form_state->getValue('weight')) && !preg_match($pattern, $form_state->getValue('weight'))) {
         $form_state->setErrorByName('weight', $this->t('This must be in a valid number format. No commas and only one decimal point.'));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $this->configuration['negate'] = $form_state->getValue('negate');
     if ($form_state->hasValue('context_mapping')) {
         $this->setContextMapping($form_state->getValue('context_mapping'));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     if ($form_state->getValue('stateFrom') === $form_state->getValue('stateTo')) {
         $form_state->setErrorByName('stateTo', $this->t('You cannot use the same state for both from and to.'));
     }
     parent::validateForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state, Request $request = NULL)
 {
     $config = $this->config('nc_register.settings');
     $parameters['TestMode'] = $config->get('nc_TestMode');
     $parameters['SandboxUsername'] = $config->get('nc_username');
     $parameters['SandboxPassword'] = $config->get('nc_api_key');
     $parameters['Password'] = $config->get('nc_api_key');
     $parameters['ipaddress'] = '46.196.142.145';
     $parameters['ClientIp'] = '46.196.142.145';
     $parameters['tld'] = $form_state->getValue('nc_api_domain_tld');
     $parameters['sld'] = $form_state->getValue('nc_api_domain_sld');
     $parameters['adminfirstname'] = $config->get('nc_adminfirstname');
     $parameters['adminlastname'] = $config->get('nc_adminlastname');
     $parameters['admincompanyname'] = $config->get('nc_admincompanyname');
     $parameters['adminaddress1'] = $config->get('nc_adminaddress1');
     $parameters['adminaddress2'] = $config->get('nc_adminaddress2');
     $parameters['admincity'] = $config->get('nc_admincity');
     $parameters['adminstate'] = $config->get('nc_adminstate');
     $parameters['adminpostcode'] = $config->get('nc_adminpostcode');
     $parameters['admincountry'] = $config->get('nc_admincountry');
     $parameters['adminphonenumber'] = $config->get('nc_adminphonenumber');
     $parameters['adminemail'] = $config->get('nc_adminemail');
     $parameters['regperiod'] = $form_state->getValue('nc_regperiod');
     require_once "../namecheap-lib/namecheap.php";
     $nc_response = namecheap_RegisterDomain($parameters);
     if ($nc_response['error']) {
         drupal_set_message($nc_response['error']);
     } else {
         drupal_set_message($parameters['sld'] . "." . $parameters['tld'] . " successfully registered");
     }
 }
 public function validateOptionsForm(&$form, FormStateInterface $form_state)
 {
     // Require a key if the format is key.
     if ($form_state->getValue(array('options', 'format')) == 'key' && $form_state->getValue(array('options', 'key')) == '') {
         $form_state->setError($form['key'], $this->t('You have to enter a key if you want to display a key of the data.'));
     }
 }
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $this->config->get('git_config.config');
     $config->set('git_url', $form_state->getValue('git_url'));
     $config->set('private_key', $form_state->getValue('private_key'));
     $config->save();
 }
 /**
  * Implements \Drupal\Core\Form\FormInterface::submitForm().
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $this->configFactory()->getEditable('meetup_pull.settings');
     $config->set('api_key', $form_state->getValue('api_key'))->save();
     $config->set('group_name', $form_state->getValue('group_name'))->save();
     parent::submitForm($form, $form_state);
 }
Example #25
0
 public function validateExposed(&$form, FormStateInterface $form_state)
 {
     if (empty($this->options['exposed'])) {
         return;
     }
     if (empty($this->options['expose']['identifier'])) {
         return;
     }
     $identifier = $this->options['expose']['identifier'];
     $input = $form_state->getValue($identifier);
     if ($this->options['is_grouped'] && isset($this->options['group_info']['group_items'][$input])) {
         $this->operator = $this->options['group_info']['group_items'][$input]['operator'];
         $input = $this->options['group_info']['group_items'][$input]['value'];
     }
     $uids = [];
     $values = $form_state->getValue($identifier);
     if ($values && (!$this->options['is_grouped'] || $this->options['is_grouped'] && $input != 'All')) {
         foreach ($values as $value) {
             $uids[] = $value['target_id'];
         }
     }
     if ($uids) {
         $this->validated_exposed_input = $uids;
     }
 }
Example #26
0
 /**
  * Form submission handler.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $author = $form_state->getValue('author');
     $body = $form_state->getValue('body');
     $title = $form_state->getValue('title');
     drupal_set_message('Thanks for submitting the form! you typed in the following as author:' . $author . ' . body:' . $body . '. title:' . $title);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->store->set('age', $form_state->getValue('age'));
     $this->store->set('location', $form_state->getValue('location'));
     // Save the data
     parent::saveData();
     $form_state->setRedirect('some_route');
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form['drivertext'] = array('#title' => $this->t('AJAX-enabled textfield.'), '#description' => $this->t("When this one AJAX-triggers and the spare required field is empty, you should not get an error."), '#type' => 'textfield', '#default_value' => $form_state->getValue('drivertext', ''), '#ajax' => array('callback' => 'ajax_forms_test_validation_form_callback', 'wrapper' => 'message_area', 'method' => 'replace'), '#suffix' => '<div id="message_area"></div>');
     $form['drivernumber'] = array('#title' => $this->t('AJAX-enabled number field.'), '#description' => $this->t("When this one AJAX-triggers and the spare required field is empty, you should not get an error."), '#type' => 'number', '#default_value' => $form_state->getValue('drivernumber', ''), '#ajax' => array('callback' => 'ajax_forms_test_validation_number_form_callback', 'wrapper' => 'message_area_number', 'method' => 'replace'), '#suffix' => '<div id="message_area_number"></div>');
     $form['spare_required_field'] = array('#title' => $this->t("Spare Required Field"), '#type' => 'textfield', '#required' => TRUE);
     $form['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit'));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     if (null != $form_state->getValue('fblikebutton_weight')) {
         if (!is_numeric($form_state->getValue('fblikebutton_weight'))) {
             $form_state->setErrorByName('fblikebutton_bl_weight', $this->t('The weight of the like button must be a number (examples: 50 or -42 or 0).'));
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $trigger = $form_state->getTriggeringElement();
     switch ($trigger['#name']) {
         case 'encrypt':
             if ($to_encrypt = $form_state->getValue('to_encrypt')) {
                 $encrypted_text = $this->encryptService->encrypt($to_encrypt, $this->entity);
                 if ($form_state->getValue('encrypt_base64')) {
                     $encrypted_text = base64_encode($encrypted_text);
                 }
                 $form_state->setValue('encrypted', $encrypted_text);
             }
             break;
         case 'decrypt':
             if ($to_decrypt = $form_state->getValue('to_decrypt')) {
                 if ($form_state->getValue('decrypt_base64')) {
                     $to_decrypt = base64_decode($to_decrypt);
                 }
                 $decrypted_text = $this->encryptService->decrypt($to_decrypt, $this->entity);
                 $form_state->setValue('decrypted', $decrypted_text);
             }
             break;
     }
     $form_state->setRebuild();
 }