Update field setting value using getFieldByHandle 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-&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);


SOLUTION

I was able to accomplish this by using setAttributes and setting the second argument $safeOnly to false

$field-&gt;setAttributes([
    'limit' =&gt; ''
],false);
MY SOLUTION

Use setAttributes and set the second argument $safeOnly to false

$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);