Issue #1938748 by mtunay: All variables were converted to CMI
[project/tcmb.git] / lib / Drupal / tcmb / TcmbCurrencySettingsForm.php
1 <?php
2 /**
3 * @file
4 * Contains \Drupal\tcmb\TcmbCurrencySettingsForm
5 */
6
7 namespace Drupal\tcmb;
8
9 use Drupal\system\SystemConfigFormBase;
10
11 /**
12 * Configure Tcmb currency settings.
13 */
14
15 class TcmbCurrencySettingsForm extends SystemConfigFormBase {
16 /**
17 * Implements \Drupal\Core\Form\FormInterface::getFormID().
18 */
19 public function getFormID() {
20 return 'tcmb_currency_settings';
21 }
22
23 /**
24 * Implements \Drupal\Core\Form\FormInterface::buildForm().
25 */
26 public function buildForm(array $form, array &$form_state) {
27 $form = array();
28 $form['tcmb_currency_codes'] = array(
29 '#type' => 'checkboxes',
30 '#title' => t('Currency Codes'),
31 '#default_value' => config('tcmb.settings')->get('tcmb_currency_codes', array()),
32 '#options' => tcmb_currency_codes(),
33 );
34 return parent::buildForm($form, $form_state);
35 }
36 /**
37 * Implements \Drupal\Core\Form\FormInterface::validateForm().
38 */
39 public function validateForm(array &$form, array &$form_state) {
40 if (!$form_state['values']['tcmb_currency_codes']) {
41 form_set_error('tcmb_currency_codes', t('You need to set some codes.'));
42 }
43 }
44 /**
45 * Implements \Drupal\Core\Form\FormInterface::submitForm().
46 */
47 public function submitForm(array &$form, array &$form_state) {
48 $tcmb_currency_codes = $form_state['values']['tcmb_currency_codes'];
49 config('tcmb.settings')
50 ->set('tcmb_currency_codes', $tcmb_currency_codes)
51 ->save();
52 parent::submitForm($form, $form_state);
53 }
54 }