Skip to main content
13 votes

How to add more options to the 'Restrict allowed file types' settings?

You can now set allowedFileExtensions and extraAllowedFileExtensions in your config file. The first will re-define the list of allowed files, where the latter will allow you to add additional file ...
Alexander Holsgrove's user avatar
6 votes
Accepted

How do I add a value to a tag field type using the entries service saveEntry method?

The Tags field classifiedTags needs an array of tag IDs, not slugs/titles. Also, if this is an existing entry and you want to retain tags already added to the field, you'll need to pull the existing ...
Mats Mikkel Rummelhoff's user avatar
5 votes

List of reserved field handles

For those wondering, here is the link to Craft 3 reserved words: https://github.com/craftcms/cms/blob/ae64588a4963b06a093636be6686345bd3a9bca8/src/base/Field.php#L190
Daron Adkins's user avatar
5 votes
Accepted

Which string identifiers for field types do exist?

I don't know if any enum exists (couldn't find it in source), but you could have a look at the contents of the craft/app/fieldtypes folder (and ignore BaseFieldtypes, DataModels and interfaces) to ...
Paul's user avatar
  • 6,338
5 votes
Accepted

How can I get the type of a field using Twig?

You can use the className function {% switch className(field) %} {% case 'craft\\fields\\PlainText' %} {% case 'craft\\fields\\Dropdown' %}
Robin Schambach's user avatar
4 votes
Accepted

How to get Category URL from field in Matrix

{{ block.linkTo.first().url() }} looks basically right, but a couple of things could be going wrong here: Does the Galleries category have a url assigned? (make sure the "Categories in this group ...
Marion Newlevant's user avatar
4 votes
Accepted

Table fields, default single empty row, and never returning as empty?

You could test if the first cell is empty {% if entry.whiskeyTableHandle|length and entry.whiskeyTableHandle[0][0] %} {% endif %} Or you simply remove all default rows in the field’s settings.
carlcs's user avatar
  • 36.3k
4 votes

Is it possible to use an existing field into a matrix?

You can use the neo Plugin or you can copy and paste the field settings manually from one field to your matrix field in your database interface. In your craft_fields table there is a column settings ...
Robin Schambach's user avatar
4 votes
Accepted

Missing Position Field Type in Matrix (Craft 3)

The "Position" field type is retired in Craft 3. You can use this: http://plugins.supercooldesign.co.uk/plugin/button-box, or this https://github.com/Rias500/craft3-position-fieldtype instead, or ...
Ottó Radics's user avatar
4 votes
Accepted

warning icon on fields

This warning appears when the content column type of the current selected field is different than the new one -> you'll lose all the information that is currently stored. For example: changing from ...
Robin Schambach's user avatar
4 votes

How to Access the Twig Attribute Name from the Fieldtype Class

Robin's answer is technically correct but I wanted to add a little more detail on how I got it working. TL;DR public function normalizeValue($value, ElementInterface $element = null) { if ( $...
kmgdev's user avatar
  • 1,199
3 votes
Accepted

More than one field for a fieldtype plugin

Nope – a single field can only have a single column in the craft_content table. If you need your FieldType to save complex data, you have two options: The easiest approach – by far – is to simply ...
Mats Mikkel Rummelhoff's user avatar
3 votes

Plugin for entries table field

This question is from a long time ago, but nowadays there's a great 3rd-party plugin that lets you do this: https://github.com/engram-design/SuperTable
Jordan Lev's user avatar
3 votes
Accepted

Plugin fieldtype settings for ColumnType::LongText being inserted as varchar(255)

The Field Types defineSettings method defines the settings that get handled when you create the field. Those field settings get stored as json in the craft_fields.settings column when the field is ...
Ben Parizek's user avatar
  • 13.5k
3 votes
Accepted

How can I make my custom FieldType show up in an element index?

To make it possible to select fields from a custom FieldType in the Customizable Element Indexes interface, your FieldType class needs to implement the IPreviewableFieldType interface, like this: ...
Mats Mikkel Rummelhoff's user avatar
3 votes
Accepted

map values from checkbox field into category field using SQL

FeedMe plugin imports categories, so you could create an xml template file that outputs your entries and their checkbox values(separated by commas), then use FeedMe to import that file back in and map ...
AbbeyDesign's user avatar
  • 1,527
3 votes

Commerce discount promotions as a fieldtype?

That field type doesn’t currently exist, but it wouldn’t be hard to create it. Here’s the relevant code you’d need if you want to take a stab at it: use Craft; use craft\base\ElementInterface; use ...
Brandon Kelly's user avatar
3 votes
Accepted

What's the difference between Neo and Matrix fields?

On first blush they are very similar. I think the Craft Plugin Store description of Neo sums it up nicely: Neo is a field type that builds upon the concept of the Matrix field type with a number of ...
RitterKnight's user avatar
  • 6,582
2 votes
Accepted

Show on user profile page the commissions he is connected to

You’d need to query for all Matrix Blocks the user is related to using a Matrix Block ElementCriteriaModel. Unfortunatelly this is not possible from the template level by default, you need to either ...
carlcs's user avatar
  • 36.3k
2 votes
Accepted

Odd error message when editing field settings (Variable "targetLocaleFieldHtml" does not exist)

This had me stumped for a while, but it turned out to be a custom fieldtype extending BaseElementFieldType, in which the settings attribute targetLocaleField apparently was renamed ...
Mats Mikkel Rummelhoff's user avatar
2 votes
Accepted

Restricting relationship field by author

Brad is correct – this isn't possible to do without writing a plugin. For your particular use case, this will be very simple, though. What you'll have to do, is to write a custom FieldType that ...
Mats Mikkel Rummelhoff's user avatar
2 votes

Restricting relationship field by author

Craft's permission system doesn't go down to the field level, which is what you're looking for. You'd either have to replicate the functionality you're looking for on the front-end of the site, or ...
Brad Bell's user avatar
  • 67.5k
2 votes

How to add more options to the 'Restrict allowed file types' settings?

The allowedFileExtensions and extraAllowedFileExtensions config options change what file types are actually allowed to be uploaded at all. To actually give more options under 'Restrict allowed file ...
Augustine Calvino's user avatar
2 votes

Where does Craft store the field definitions?

Basically look for the tables "craft_fields", "craft_content" and "craft_sections". For Fields you can use the "Field Manager" Plugin.
phaetons's user avatar
  • 705
2 votes
Accepted

How to Access the Twig Attribute Name from the Fieldtype Class

Because of several reasons it won't work the way you are going to do it. The easiest approach is to return an object or an array instead of single value in your normalize functions that contains the ...
Robin Schambach's user avatar
2 votes
Accepted

Craft CMS 3 data structure advice for vehicle make, model, trim, year tagging

Goal: Filter documents by related vehicle characteristics. My first idea would be to create it as such: Create an assets volume where all your documents will be uploaded to. Create a vehicle ...
Tom De Smet's user avatar
  • 1,456
2 votes

Pre-fill fields when creating an entry in CP

This functionality could be created in a plugin or module, but why wouldn't you duplicate the entry and change the fields you need to change?
Paul's user avatar
  • 6,338
2 votes

Values from fields in templates

This is all covered in the Craft CMS documentation: {% for option in entry.<FieldHandle> %} Label: {{ option.label }} Value: {{ option }} or {{ option.value }} {% endfor %}
Jamie Wade's user avatar
  • 3,644
2 votes

Loop through all created fields and get the field type

Making sure you include use craft\db\Query; at the top of your Class, you can do something like this: $fields = (new Query()) ->select(['id','handle','name','instructions','type']) ->...
Oli's user avatar
  • 7,495
2 votes

What will happen if we change the field type in the fields (settings -> fields) in Craft 3?

It depends on the field type. Many of them you can change without problems, while others would make no sense. If you are, for instance, changing a text field to an image field, Craft obviously wouldn'...
KSP's user avatar
  • 849

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