Answers.Body: <p>As far as accessing the value of the setting, try: </p>
  
  <pre><code>$plugin = craft()-&gt;plugins-&gt;getPlugin('pluginHandle');
  $plugin-&gt;getSettings()-&gt;getAttribute('pluginSettings1');
  </code></pre>
  
  <p>If you need to access your settings throughout your services file you might also create a global variable.</p>
  
  <pre><code>class PluginHandleService extends BaseApplicationComponent
  {
      public $settings = array();
  
      public function __construct()
      {
          $this-&gt;settings = $this-&gt;initSettings();
      }
  
      private function initSettings()
      {
          $plugin = craft()-&gt;plugins-&gt;getPlugin('pluginHandle');
  
          $settings = array();
          $settings['pluginSettings1'] = $plugin-&gt;getSettings()-&gt;getAttribute('pluginSettings1');
  
          return $settings;
      }
  
      // other service methods
  
  }
  </code></pre>
  
  <p>Which you can then access like this:</p>
  
  <pre><code>$this-&gt;settings['pluginSettings1']
  </code></pre>
  
  <p>Thanks to André Elvan for help on <a href="https://craftcms.stackexchange.com/a/3028/784">setting up a constructor</a>.</p>
  
  <p><strong>Update</strong></p>
  
  <p>As far as assigning a value however, I think you may have to use the 'default' property. In the past I have successfully done this with strings like so:</p>
  
  <pre><code>protected function defineSettings()
  {
      return array(
          'pluginSettings1' =&gt; array(AttributeType::String, 'default' =&gt; "value"),
  }
  </code></pre>
  
  <p>I presume you could do the same with 'Mixed', although never tried:</p>
  
  <pre><code>protected function defineSettings()
  {
      return array(
          'pluginSettings1' =&gt; array(AttributeType::Mixed, 'default' =&gt; 'active_features' =&gt; array('change_team' =&gt; false, 'change_series' =&gt; false, 'change_user_settings' =&gt; false))),
  }
  </code></pre>
  
  <p>It might make more sense to break the array into individual settings, however.</p>
  
  <pre><code>protected function defineSettings()
  {
      return array(
          'change_team'          =&gt; array(AttributeType::Bool, 'default' =&gt; 'false',
          'change_series'        =&gt; array(AttributeType::Bool, 'default' =&gt; 'false',
          'change_user_settings' =&gt; array(AttributeType::Bool, 'default' =&gt; 'false',
      ),
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-25T01:26:05.470Z
Answers.Text: Awesome, thanks for the help!
  
  I think there's a problem with the array structure I am using for "defineSettings()":
  
  Because $settings['change_team'] returns: PHP notice "Trying to get property of non-object", and  $settings['pluginSettings1'] returns: array(1) { ["pluginSettings1"]=> NULL }
Answers.UserDisplayName: taylor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-25T06:36:31.930Z
Answers.Text: I wasn't really paying attention to how you were assigning the values. I updated the answer — hopefully this is on the right track.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-25T07:18:04.707Z
Answers.Text: The last suggestion (breaking array into individual settings) made more sense and after trying it, I was able to get things working perfectly. I can't thank you enough for helping out with this man!
Answers.UserDisplayName: taylor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-25T00:41:03.767Z
Answers.LastActivityDate: 2017-02-21T00:56:46.083Z
Answers.LastEditDate: 2017-04-13T12:51:00.253Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I have two small arrays I want to store in my plugin settings, though I'm stuck at what the AttributeType:: should be, as well as how to retrieve the actual values. The arrays I want to store look like:</p>
  
  <pre><code>'active_features' =&gt; [
       'change_team' =&gt; false,
       'change_series' =&gt; false,
       'change_user_settings' =&gt; false,
  ],
  </code></pre>
  
  <p>In my plugin file (pluginHandlePlugin.php) I see I can do something like this:</p>
  
  <pre><code>protected function defineSettings()
  {
      return array(
          'pluginSettings1'   =&gt; array(AttributeType::Mixed, 'active_features' =&gt; array('change_team' =&gt; false, 'change_series' =&gt; false, 'change_user_settings' =&gt; false)),
      );
  }
  </code></pre>
  
  <p>And getting those values through the service file works like:</p>
  
  <pre><code>public function getPluginSettings()
  {
  $plugin = craft()-&gt;plugins-&gt;getPlugin('pluginHandle');
  $settings = $plugin-&gt;getSettings();
  
  return $settings;
  }
  </code></pre>
  
  <p>Which works, and returns the object for me. However I'm unable to get to the actual key/values from the original array, I've tried:</p>
  
  <pre><code>return $settings-&gt;pluginSettings1;
  </code></pre>
  
  <p>But that returns NULL</p>
  
  <p>So, how do I retrieve the keys/values, and also, what is the best AttributeType:: to set for this? I've looked around for AttributeType:: options and details but didn't find anything.</p>
  
  <p>Any help would be GREAT! Thanks!</p>
  
Tags: <plugin-development><php><services><settings>
Title: Plugin Settings: Attribute Types, and how to receive
ThreadText: # Plugin Settings: Attribute Types, and how to receive
  
  (Asked by: username_0 on 2015-02-24)
  
  I have two small arrays I want to store in my plugin settings, though I'm stuck at what the AttributeType:: should be, as well as how to retrieve the actual values. The arrays I want to store look like:
  
  ```
  'active_features' => [
       'change_team' => false,
       'change_series' => false,
       'change_user_settings' => false,
  ],
  
  ```
  
  In my plugin file (pluginHandlePlugin.php) I see I can do something like this:
  
  ```
  protected function defineSettings()
  {
      return array(
          'pluginSettings1'   => array(AttributeType::Mixed, 'active_features' => array('change_team' => false, 'change_series' => false, 'change_user_settings' => false)),
      );
  }
  
  ```
  
  And getting those values through the service file works like:
  
  ```
  public function getPluginSettings()
  {
  $plugin = craft()->plugins->getPlugin('pluginHandle');
  $settings = $plugin->getSettings();
  
  return $settings;
  }
  
  ```
  
  Which works, and returns the object for me. However I'm unable to get to the actual key/values from the original array, I've tried:
  
  ```
  return $settings->pluginSettings1;
  
  ```
  
  But that returns NULL
  
  So, how do I retrieve the keys/values, and also, what is the best AttributeType:: to set for this? I've looked around for AttributeType:: options and details but didn't find anything.
  
  Any help would be GREAT! Thanks!
  
  **Tags:** plugin-development, php, services, settings
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-02-25. Score: 4 | Accepted answer
  
  As far as accessing the value of the setting, try:
  
  ```
  $plugin = craft()->plugins->getPlugin('pluginHandle');
  $plugin->getSettings()->getAttribute('pluginSettings1');
  
  ```
  
  If you need to access your settings throughout your services file you might also create a global variable.
  
  ```
  class PluginHandleService extends BaseApplicationComponent
  {
      public $settings = array();
  
      public function __construct()
      {
          $this->settings = $this->initSettings();
      }
  
      private function initSettings()
      {
          $plugin = craft()->plugins->getPlugin('pluginHandle');
  
          $settings = array();
          $settings['pluginSettings1'] = $plugin->getSettings()->getAttribute('pluginSettings1');
  
          return $settings;
      }
  
      // other service methods
  
  }
  
  ```
  
  Which you can then access like this:
  
  ```
  $this->settings['pluginSettings1']
  
  ```
  
  Thanks to André Elvan for help on [setting up a constructor](https://craftcms.stackexchange.com/a/3028/784).
  
  **Update**
  
  As far as assigning a value however, I think you may have to use the 'default' property. In the past I have successfully done this with strings like so:
  
  ```
  protected function defineSettings()
  {
      return array(
          'pluginSettings1' => array(AttributeType::String, 'default' => "value"),
  }
  
  ```
  
  I presume you could do the same with 'Mixed', although never tried:
  
  ```
  protected function defineSettings()
  {
      return array(
          'pluginSettings1' => array(AttributeType::Mixed, 'default' => 'active_features' => array('change_team' => false, 'change_series' => false, 'change_user_settings' => false))),
  }
  
  ```
  
  It might make more sense to break the array into individual settings, however.
  
  ```
  protected function defineSettings()
  {
      return array(
          'change_team'          => array(AttributeType::Bool, 'default' => 'false',
          'change_series'        => array(AttributeType::Bool, 'default' => 'false',
          'change_user_settings' => array(AttributeType::Bool, 'default' => 'false',
      ),
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Awesome, thanks for the help!  I think there's a problem with the array structure I am using for "defineSettings()":  Because $settings['change_team'] returns: PHP notice "Trying to get property of non-object", and  $settings['pluginSettings1'] returns: array(1) { ["pluginSettings1"]=> NULL }  
  > **username_1**: I wasn't really paying attention to how you were assigning the values. I updated the answer — hopefully this is on the right track.  
  > **username_0**: The last suggestion (breaking array into individual settings) made more sense and after trying it, I was able to get things working perfectly. I can't thank you enough for helping out with this man!  
  
  ---
  
  