Skip to main content
1 vote
Accepted

Craft 3 site – users suddenly cannot login to back-end

Assuming you're running Craft version 3.4.27 or earlier, most likely your web host has updated MySQL and you're running into this issue: https://github.com/craftcms/cms/issues/6379 The fix is to ...
Mats Mikkel Rummelhoff's user avatar
1 vote

How can I display a message to the user that the field is filled in incorrectly?

After calling saveElements, if saving failed due to validation errors, those errors will be available through the $family entry. The way to show those errors to the user is to provide this model back ...
MoritzLost's user avatar
  • 11.6k
1 vote

How can I check the size of the file uploaded via the form?

You can check the size property on the UploadedFile instance. $limit = 2_097_152; if ($uploadedFile->size > $limit) { // abort and return an error message }
MoritzLost's user avatar
  • 11.6k
1 vote

How to check an elements elementType

This is a trick I always use when I want the "base name" of a class: // if $element is an instance of \craft\elements\Entry $baseName = array_reverse(explode('\\', get_class($element)))[0]; /...
7ochem's user avatar
  • 175

Only top scored, non community-wiki answers of a minimum length are eligible