Questions tagged [custom-fieldtype]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
13 views

Register own FieldType in Craft 3.x

I have the following struggle. I tried to register my FieldType in my init function of the module.php. Event::on( Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, function(...
1 vote
1 answer
17 views

Craft 3, Multi site setup - Update title for entry 1 site only

My setup: Craft 3 installation with a multi-site setup. 3 languages, all enabled. I have a custom plugin with a custom element type, FooBar that extends the Element class and a custom FooBar field ...
1 vote
1 answer
57 views

Custom Field Types File upload returns null

I am working on a plugin which adds a custom field type. The field type should allow the upload of a file, which is then sent to another server (thus not a normal asset, as it is only temporarily ...
2 votes
1 answer
73 views

Can I change a user field with twig without using a form?

I basically just want to set the value of a users field to a different number if something happens, so that the user field is actually updated in the CMS. Can I do that without creating a form? So ...
1 vote
1 answer
21 views

Get field settings of custom field via ElementInterface

It is possible to get the field settings via ElementInterface in normalizeValue Method ? I need these settings of my custom field from my plugin : how i can get now these values inside normalizeValue ...
1 vote
1 answer
58 views

How to build a custom fieldtype containing multiple nested groups of text and dropdown pairs?

I'm working on what I thought would be a relatively simple plugin; a custom fieldtype that would have 8 "sub-groups", each of which would consist of a numeric text field and a dropdown field ...
1 vote
1 answer
49 views

Structure Navigation with 3 possible Link Types using Nav tag

I'd like to build a Structure that can be used to output the main site navigation; each "entry" in the Structure would have three custom fields (types): Category, Entries, URL This question ...
1 vote
1 answer
108 views

Smart Map plugin, HAVING SQL and GROUP BY elements.id

It seems like most Craft queries contain GROUP BY elements.id but this seems to clash with a HAVING clause when using the Smart Map plugin. Where does this come from and is it possible to override/...
1 vote
2 answers
152 views

Creating a custom, "multiple dates picker" field

We're migrating* a website that uses http://dubrox.github.io/Multiple-Dates-Picker-for-jQuery-UI/ to store any combination of dates for an entry... (eg not just a single date or date range, can be ...
2 votes
1 answer
406 views

Trouble finding the correct path to template in custom module and getting the "Unable to find the template" error

I've created a custom module trying to implement new field types. I'm using How to create custom field type in Craft 3 and https://github.com/mmikkel/IncognitoField-Craft3 as reference on how to ...
3 votes
1 answer
426 views

onAfterElementSave and new elements

I have a field type that needs to do some processing, based on the data in the element it belongs to, when an element (entry, category, user, etc) is saved, and save it to the field. I'm hooking into ...
1 vote
2 answers
203 views

Custom Fieldtype with Checkboxes - Remove value and set to null when checkboxes are left blank

I created a custom field type to show user groups in a checkbox layout, e.g. (http://cl.ly/image/0A1a140m031h). I am running into one small issue. If I add content with a checkbox(s) option selected ...
7 votes
3 answers
17k views

How do I prevent Twig from encoding HTML?

I've created a field type that stores its value as a model. That model’s __toString() method returns the result of a craft()->templates->render() call: public function render() { $render = ...
4 votes
1 answer
3k views

How to create custom field type in Craft 3

I have been struggling to create my own custom field, so I would like to ask how to create it. First of all, I don't know where the files should be in. I have some custom fields in Craft 2. It might ...
1 vote
1 answer
457 views

Custom field plugin: Unable to find template / General custom field plugin information

I am still relatively new to Craft CMS. I am trying to make a custom field plugin for Craft 3 but I am struggling to understand why I can't render my form template. The fieldtype should render a map ...
1 vote
1 answer
284 views

Custom plugin field in Table Columns?

I just created my first Craft 3 plugin. In the plugin I also have a custom (select)field. Everything is working as expected, which is great! But I can't for the life of me figure out, how to add this ...
3 votes
2 answers
1k views

Plugin Error: "Unable to find component class"

I'm suddenly getting an error on my plugin fieldtype even though I didn't make any changes to it. On Craft's publish page where my field is supposed to be I get the error: Unable to find component ...
1 vote
0 answers
123 views

Element type vs. Field type - or: Element type without database storage?

I have already searched for information on this topic but I did not find much. I hope I did not overlook something. My problem is the following: I want to try to write a plugin that lists entries ...
1 vote
1 answer
173 views

Saving a "craft-linkfield" field via an entry form

I'm editing an entry via an entry form as documented here: https://docs.craftcms.com/v3/dev/examples/entry-form.html How would I be able to save a link field that's using https://github.com/sebastian-...
3 votes
1 answer
32 views

Partial Dates within Craft

Is it possible to store partial dates? EG i want to create a document that covers a date range, sometimes that range could be Jan/2013 to JUN/2014 other times we may need it more specific EG 20/JAN/...
2 votes
1 answer
78 views

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

Hi i really would like some advise on best practices on setting up some data for my Craft APP. Most of my documents will be linked to vehicle make/model/trim/year. EG Audi A5 Sport 2009-2016 and/Or ...
1 vote
2 answers
287 views

Multiple Category Sources Field

I want to utilise the Category field type but with the ability to choose from multiple category sources (as with Entries). I noted in cms/src/fields/Categories.php that $this->allowMultipleSources ...
5 votes
1 answer
1k views

How to reference the current entry element in custom Control Panel templates?

This might provide it's own answer, but I thought I would ask to be sure. How do you reference the current entry in custom fieldType or CP templates? I have tried {{ entry.id }}, {{ element.id }} but ...
0 votes
0 answers
88 views

Custom plugin: asset fieldtype

I have a custom plugin that uses a custom field leveraging the elementSelect fieldtype to select an asset (which is then processed on submission via a custom service). However, when I select an asset ...
0 votes
1 answer
208 views

Custom Plugin Field Using Wrong Template Path

I'm trying to build a simple dropdown field with a pre-populated set of options, so I figured I'd just import most of the methods from Craft's native Dropdown field. The plugin name is siteutilities ...
1 vote
2 answers
93 views

Assets metadata: Matrix required?

I'd like to add very basic metadata to assets (Alttext, Caption..) I noticed in volumes you can add custom field types – but they're not appearing when editing the entry. I found it can be edited in ...
3 votes
1 answer
959 views

How to query entries by field values

I have some entries with a multi-select field called "gallery". We can choose many images to this field. I have a given image, how can I query entries whose "gallery" contains this given image? Thx! ...
1 vote
0 answers
31 views

Get Entries with a specified. Custom FieldType

I have created a Custom FieldType with AttributeType::Mixed The field actually saves the a Custom Model I created. I'm trying to retrieve all the entries that have my custom model as the field. I'm ...
1 vote
1 answer
56 views

Input Tags Template for my Custom FieldType

I created a custom FieldType that gathers data from 2 different Models. I was able to successfully display it as a Drop Down. My problem now is that there are tooo many records on my array and I would ...
1 vote
1 answer
48 views

Custom Pluging Entries FieldType

I have 2 plugins I created that store similar data: Plugin 1: id, name, panel_id, price Plugin 2: id, name, test_id, price I want to attach my plugin data to an entry, and I need to make sure they ...
1 vote
2 answers
1k views

How can I get entry id in field

I create a new filed type and attached it to entries. Now I need to get the entry id which the field is attached to. I tried $this->element in my field class, but got an error said that I'm ...
1 vote
0 answers
193 views

How do you query entries by field value for multi-select field type? [duplicate]

I am looking to query entries by a field value. The value will be a dynamic variable but i cannot get any results showing with hardcoded state. This is the code i have so far: $entries = Entry::...
1 vote
1 answer
192 views

Plugin field-type not getting javascript variable?

Updating a plugin from Craft 2 to Craft 3, so this logic used to work. The plugin has a field-type which is a button. When clicked, the button does stuff depending upon another field. That handle(ID) ...
1 vote
1 answer
76 views

Unable to render a plugin template

Creating a plugin that contains a custom field. I need to have some custom html for the settings of the field. I have the following in my field class: /** * @inheritdoc */ public function ...
3 votes
2 answers
316 views

How does a plugin output JS that can be used within a cache tag?

Google Maps for Craft outputs data into script tags to add markers to map with Javascript. Everything works great until a user goes to cache the output of an entries loop. It works upon first page ...
1 vote
1 answer
107 views

What is $source and $sources in BaseRelationField?

I see the following in BaseRelationField: public function settingsAttributes(): array { $attributes = parent::settingsAttributes(); $attributes[] = 'sources'; $attributes[] = 'source'; ...
1 vote
1 answer
32 views

Getting `modifyUserSortableAttributes` to work during plugin development

I have a plugin that is creating a custom field. I am using the modifyUserSortableAttributes method to make my field appear in the columns available for the Users Table and wanted to be able to sort ...
2 votes
2 answers
1k views

Adding Columns to a table

Is there a way or a plugin that allows you to add columns and change columns heading from within the entry? Instead of defining column heading while creating the table field. It would be nice to have ...
1 vote
1 answer
706 views

Use a custom field type in Matrix Blocks - Craft 3

I'd like to create a field of type Dropdown/Table (or even use a field from a plugin like color-swatches) and have it available when selecting a matrix block element field type: In this case, it's ...
1 vote
0 answers
252 views

Can't dynamically add value to hidden input Sprout field

I'm trying to add a hidden input with Sprout forms and Sprout fields but I can't dynamically add a value to the input attribute. I have a custom form template in craft/templates/_forms/field.html in ...
2 votes
2 answers
339 views

Is it possible to populate admin form with data supplied by an external API?

I've been tasked with reviewing Craft as a potential solution for the company I work for and one of the requirements is that we need to be able to provide data from a external API in the page creating/...
1 vote
2 answers
247 views

Retrieve entries on custom field date using ElementCriteriaModel

I am trying to retrieve an array of entries on a particular section where inspectionDate is greater than today's date. Here is the code. $criteria = craft()->elements->getCriteria(ElementType::...
1 vote
1 answer
99 views

How to set url of delete button of editableTableField?

As title says, I have a URL which I need to call when someone clicks on delete button. I already have a primary key which I need to set and append in delete URL. How'd I do that? Update Rows are ...
1 vote
1 answer
94 views

Using data within a mixed attribute type to query Craft entries dates

I wish to have a custom fieldtype which contains the standard datetime field abilities along with storing an extra piece of data. I have created a custom fieldtype for this with a mixed attributetype ...
2 votes
1 answer
828 views

More than one field for a fieldtype plugin

I can have many 'settings' fields for a fieldType and they're saved as a serialized string in the database. Is it possible to have more than one field for the fieldType itself? It looks like there's ...
1 vote
1 answer
698 views

Creating a Custom Field Type with nested Fields [duplicate]

I'm just wondering is it possible to have nested Fields inside of a Custom Field type. So if I create a custom Field type. I wish for it to contain all of the following. So it will contain multiple ...
2 votes
2 answers
929 views

Add an assets field to a field type plugin template

I have a plugin that creates custom field types to extend crafts default field types. The custom field types hold several different form input fields. For example the field may be called video and ...
2 votes
0 answers
90 views

Custom fieldtype to add text field to dropdown, radiobuttons and checkboxes

In my plugin I need to create a fieldtype of a dropdown, radiobutton or checkbox combined with a textfield. I've gone ahead and created a custom field type using the description here https://craftcms....
0 votes
1 answer
214 views

Get owner entry from fieldtype

I have a custom fieldtype (used within Neo block) and I need to know the ID/content of entry it belongs to, when editing the entry. I need to both populate field values based on value in other field (...
1 vote
1 answer
332 views

Filtering values from Twig for my custom field type

I have a custom fieldtype for Craft which stores its value as an array of Models using AttributeType::Mixed. See below for an example of the FieldType and Model setup class MyCustomFieldType extends ...