People who code: we want your input. Take the Survey

Questions tagged [custom-field]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
12
votes
1answer
2k views

How to add custom user fields to the front end registration page

This question is similar to this post, but more of the next logical step. I have added custom fields to my user profiles, but would like these attributes to be part of the registration page. For ...
9
votes
2answers
998 views

Is it possible to output the name of a Matrix Block?

I'd like to output the Names of Matrix Blocks. I know you can filter by block types e.g. {% for block in entry.myMatrixField.type('text, heading') %} {% if block.type == "heading" %} <h3>{{ ...
7
votes
2answers
824 views

Best way to use custom enums in my plugin templates?

I am building a plugin that's uses an enum for custom statuses. The statuses are integrated within my plugin with the exception of changing the status in my template code. pluginname/enums/...
6
votes
1answer
2k views

How can I update custom order fields in the frontend

I am struggling with using additional custom order fields. (Added in the Craft Commerce settings at "order fields", in the field layout manager) I try to update them like this in the checkout process:...
6
votes
1answer
480 views

Display thumbnail using defineTableAttributes for a custom Element Type

Hi, I'm new to Craft and VERY new to plugin development. I'd like to display a thumbnail image in my table list view and thought it would be possible to accomplish using a new Custom Element Type. ...
5
votes
2answers
587 views

How can I limit a list based on a custom date field

I a trying to display a simple event listing. I set up a custom date field called eventDate to note when the event happens. This code delivers me the list of events sorted by eventDate: {% for ...
5
votes
1answer
697 views

“Excerpt” option in Redactor?

I love using the excerpt option in Wygwam (CKEditor). I've looked high and low but as of yet, have been unable to find a way to have an exceprt show short of having a whole second field. I have seen a ...
5
votes
1answer
217 views

Entry with many fields vs plugin/custom data structure

i'm just getting my feet wet with craft and would appreciate some pointers. Basically, what i would like to do is show and compare products. Each product will have a description, price, review, and ...
3
votes
2answers
1k views

Craft's Content Table

I'm essentially in the process of learning Craft and in that process have made some great strides. Today I was examining Craft's tables to see how it was actually storing fields created through ...
3
votes
3answers
824 views

Option and notes fields after cart at checkout for order, not just line items

My client has gift wrapping services but they apply to the entire order, not one single line item. How would I add notes or custom fields to the entire order, at the shipping stage of checkout? is ...
3
votes
1answer
1k views

Display custom product field in cart

How would I access a custom product field in the cart. I did it with the snapshot attribute like so: {# cart.html #} {% for item in cart.lineItems %} {{ craft.commerce.products.id(item.snapshot....
3
votes
1answer
414 views

How is Craft able to reuse fields in different Sections? (As opposed to EE.)

I'm a HUGE fan of Craft, but I'm wondering how specifically it's able to reuse fields in different sections. I'm very accustomed to an ExpressionEngine environment, where each field's shortname has to ...
3
votes
1answer
454 views

How does a plugin make use of Craft's storage?

I am building a plugin that needs to cache generated images into a directory in Craft, presumably the craft/storage directory. I took a glance in the docs, but couldn't find much in the form of how to ...
3
votes
2answers
513 views

How to store custom data into a user

I need some direction in how to store (complex) data into users (best practice) I'm working on a project for a fitness app. I created a structure with 2 levels for workouts where level 1 entries are ...
3
votes
1answer
560 views

Custom field type that has multiple fields to extend the default field types

Ok scenario that I'd like to create. Create a custom field type lets call it videos. In this field type you would have 5 separate fields title, description, caption, link, thumb. This would make up ...
3
votes
1answer
280 views

Can a model or record have conditional requirements?

I have a form that spans two pages, with a required field on both pages and an optional field on both pages: Form A - Page 1 - Question 1 (required) - Question 2 (optional) [User submits partial ...
3
votes
1answer
29 views

Use own/custom field inside Craft Table

I made my own, fairly simple field inside a Module for Craft 3.x. What settings do i need to define to make it usable inside a table?
3
votes
1answer
28 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
2answers
833 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 ...
2
votes
1answer
63 views

date in database -1 day as on frond-end

We just found out that in the database birthday field, all dates has 1-day difference than what is shown on the front-end. On the front-end, it is the correct date by the way. Question: Is it a bug ...
2
votes
1answer
143 views

Unable to store Model in Commerce Order Fields

I'm trying to use custom order fields in Craft Commerce to store a reference to an object, but all I am getting back is an ElementCriteria model. I have two custom order fields defined: twoDayOption ...
2
votes
1answer
131 views

saving user field type custom field - Failed to set unsafe attribute

I have tried to save a custom field of "user field" type which resulted in this error. "Failed to set unsafe attribute" code: $order->setAttributes(array( 'operatorUid' => Craft::$app-&...
2
votes
1answer
742 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 ...
2
votes
2answers
460 views

Populate or change the selection options in one field based on selected option in another field in the CP

I'm looking to change a select fields options with the onChange event from another select fields chosen option. Obviously this can be done with js on the frontend as per this post but has anyone done ...
2
votes
1answer
395 views

Entries search query by 2 custom fields

So I have a Entry type that has two custom fields on it. Both fields are integer fields. I'd like to make a query in PHP that gets the entries by two custom fields, both of which are integer values. ...
2
votes
1answer
159 views

How can additional custom fields be added to the Sites settings?

In Craft 3 Sites, there are some default fields like language, handle, etc. I would like to add additional fields. Is this possible. Specifically, I want to add an Image field so we can add a flag ...
2
votes
1answer
286 views

Get future multi-day event entries with custom date field

I have an event section with custom fields for eventDate and eventEndDate. I'm listing upcoming events in my template using: {% for event in craft.entries.section('events').eventDate('>='~now)....
2
votes
1answer
1k views

Using the required field validation in custom element types/plugins?

I am finishing up the last few details on my custom element type. I have custom statuses and public submissions working. The last detail is providing validation on custom fields set through the field ...
2
votes
2answers
253 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/...
2
votes
1answer
785 views

Make fields conditionally required

Is there a way to make fields conditionally required? I have a toggle field that is used to hide or show a section (see screenshot: "Section 3 enabled"). If the section is shown (toggle: on), the ...
2
votes
1answer
63 views

Save same Entry more than once with help of custom relations field

Is it possible to save the same Entry (red arrow) twice/more than once in one custom relations field? "Test Playlist" is a entry in a channel. Background: I have set up a playlist, where an entry ...
2
votes
2answers
870 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 ...
1
vote
2answers
242 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
1answer
2k views

How to save a new entry with custom fields - Craft 3

I'm trying to create a new Entry via PHP, with custom fields (Craft 3). I can save it, however my custom fields don't appear. I've tried using setFieldValue, as well as $entry->excerpt = 'Lorem...';...
1
vote
1answer
167 views

How do I set the value of a custom entries order field from a plugin?

I'm trying to set the value of a custom field on an order when saving an entry. I found an example of how to do this for a simple text field, but the field I'm trying to set is an entries field, not ...
1
vote
1answer
100 views

How to pull out all user data in a template?

I'm trying to pull out user data in a template for specified user profiles whilst the current user is logged in. To do this I check on the userId being referenced and use: {% if userId != currentUser....
1
vote
1answer
299 views

Return entries where custom field partially contains

My entries have a field containing a third-party product id and a price, separated by a hyphen, like so: p666a-12.99 In the template, a plugin is returning me some product ids, and I want to return ...
1
vote
1answer
18 views

Countries Field for Freeform

The Freeform docs say there is a predefined option for Countries, but I do not see it anywhere in the Field types or existing fields. How does one access this? Using the latest version of both Craft ...
1
vote
1answer
118 views

Add Checked Attribute to Custom User Fields on Frontend User Form

I have a multi-select for users to sign up for newsletters. When they edit their profile they need to be able to see which newsletters they are already signed up for. I have the code to output the ...
1
vote
2answers
186 views

Custom fields on a structure or section archive page

I have a section (or structure, works both) for "events". On the archive template (see image below) I want to add a custom image in the header. The administrator needs to be able to upload the header ...
1
vote
1answer
278 views

Custom Field on Settings page

I would like to have a custom field on the general settings page where I can enter the meta description for the website. Can this be achieved somehow? Another way I could think of is to add such a ...
1
vote
1answer
65 views

Checking value of customer order field within Plugin

I am trying to check the value of a checkbox as part of my checkout process. I have the following function at the moment. public function init() { craft()->on('commerce_orders....
1
vote
1answer
790 views

customised slugs using custom field

I have a 'Profile' channel that gives the profile of people. I have 'Last name' as the title, 'first name' and I'd like to use first name in the slug rather than have to add the first name to the ...
1
vote
1answer
271 views

Why won't the values of an editableTableField show up in my template?

I'm still trying to process my csv data as mentioned in a former question. But I'm struggling with another part of this right now. I decided to implement a custom field type which should display the ...
1
vote
1answer
31 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
1answer
32 views

How to set the value of a Date field from PHP?

I'd like to set the value of a Date field from my custom PHP code. How can this be made? Which format does the Date field expect when using the setValue() function?
1
vote
2answers
61 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 ...
1
vote
1answer
110 views

How can retrieve users custom fields only?

I have created fields for users and also entry type. I want to get only users fields. I have retrieved custom fields but that returns all the fields. $users = \craft\elements\User::find()->id(...
1
vote
2answers
345 views

how to search for entries where a custom field is either not present or is empty

Some of my entries have the optional plaintext field myCustomField. I want to retrieve all entries except those where myCustomField is filled out. I can get all entries that have an empty ...
1
vote
1answer
117 views

Solspace Calendar: custom fields not outputting

I'm unable to get custom fields to output using Solspace Calendar on Craft3. I am not getting any errors indicating that the field does not exist, it's just not outputting. The field is a Redactor ...