Answers.Body: <p>MY SOLUTION</p>
  
  <p>Use <code>setAttributes</code> and set the second argument <code>$safeOnly</code> to false</p>
  
  <pre><code>$fieldsService = Craft::$app-&gt;getFields();
  $field = $fieldsService-&gt;getFieldByHandle('productImages');
  // Update 'limit' value to be empty in order to accept as many images as needed
  $field-&gt;setAttributes([
      'limit' =&gt; ''
  ],false);
  $fieldsService-&gt;saveField($field);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-20T23:42:06.913Z
Answers.LastActivityDate: 2018-10-20T23:42:06.913Z
Answers.UserDisplayName: Hector
Body: <p>I need to update the limit setting for Images allowed to be empty, so as to allow for no limit. How do I go about updating the 'limit' setting?</p>
  
  <pre><code>$fieldsService = Craft::$app-&gt;getFields();
  $field = $fieldsService-&gt;getFieldByHandle('productImages');
  // Need to update 'limit' to equal '' (currently limited to '5')
  // Then save the new setting
  $fieldsService-&gt;saveField($field);
  </code></pre>
  
  <p><strong><em>SOLUTION</em></strong></p>
  
  <p>I was able to accomplish this by using <code>setAttributes</code> and setting the second argument <code>$safeOnly</code> to <code>false</code></p>
  
  <pre><code>$field-&gt;setAttributes([
      'limit' =&gt; ''
  ],false);
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-19T04:48:36.767Z
Comments.Text: `$field->limit = '' ` does the trick as well
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-20T02:54:05.713Z
Comments.Text: @Hector can you add what worked for you as an official answer?
Comments.UserDisplayName: Brad Bell
Tags: <plugin-development><field><image><limit>
Title: Update field setting value using getFieldByHandle
ThreadText: # Update field setting value using getFieldByHandle
  
  (Asked by: username_0 on 2018-10-18)
  
  I need to update the limit setting for Images allowed to be empty, so as to allow for no limit. How do I go about updating the 'limit' setting?
  
  ```
  $fieldsService = Craft::$app->getFields();
  $field = $fieldsService->getFieldByHandle('productImages');
  // Need to update 'limit' to equal '' (currently limited to '5')
  // Then save the new setting
  $fieldsService->saveField($field);
  
  ```
  
  ***SOLUTION***
  
  I was able to accomplish this by using `setAttributes` and setting the second argument `$safeOnly` to `false`
  
  ```
  $field->setAttributes([
      'limit' => ''
  ],false);
  
  ```
  
  **Tags:** plugin-development, field, image, limit
  
  > **Comments:**
  > **username_1**: `$field->limit = '' ` does the trick as well  
  > **username_2**: @username_0 can you add what worked for you as an official answer?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-10-20. Score: 2 | Accepted answer
  
  MY SOLUTION
  
  Use `setAttributes` and set the second argument `$safeOnly` to false
  
  ```
  $fieldsService = Craft::$app->getFields();
  $field = $fieldsService->getFieldByHandle('productImages');
  // Update 'limit' value to be empty in order to accept as many images as needed
  $field->setAttributes([
      'limit' => ''
  ],false);
  $fieldsService->saveField($field);
  
  ```
  
  
  ---
  
  