1

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);
| improve this question | | | | |
  • 1
    $field->limit = '' does the trick as well – Robin Schambach Oct 19 '18 at 4:48
  • @Hector can you add what worked for you as an official answer? – Brad Bell Oct 20 '18 at 2:54
2

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);
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.