Questions tagged [attribute]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
1answer
23 views

Setting valueless boolean attributes with the tag function

When using the tag function, how does one handle valueless attributes which could also be null? For example, it's great we can do… {% set idVar = 'idstring' %} {% set nameVar = 'namestring' %} {% ...
2
votes
2answers
792 views

Add custom attribute to standard element from plugin

Developing plugin for Craft 3, I want to add extra property to Assets (data being pulled from other table) I am able to pull in the data by extending element query: Event::on( ...
2
votes
1answer
108 views

Model values assignment issue

I am setting attributes on my record using a models' attributes (that has validated successfully). I cannot figure out why the values aren't assigned. I can manually assign each one but that's ...
1
vote
0answers
136 views

Table attributes not customisable for nested entry sources [closed]

Using a plugin, I have added some nested entry sources to some of the default section entry sources in my site. For example: 'section:6' => [ 'label' => 'News', ... 'nested' => [...
3
votes
1answer
864 views

Model/Record AttributeType documentation?

I'm building a plugin which creates a few tables, and need to store some fairly robust data. I've done this before and previously gotten by with mostly AttributeType::String and AttributeType::Mixed, ...
1
vote
2answers
321 views

Validating Date of Birth format from a form field value

I'm working a on website project which includes a web form which asks for various personal details, one of the fields on the form is Date of Birth. The form is being validated by a custom plugin ...
1
vote
0answers
51 views

Change existing EntryModel custom attribute values [duplicate]

I am trying to change custom field values of a existing entry, but it won't save them in the database. It saves it on the model but the entry isn't persisted to the database. craft()->on('...
1
vote
1answer
244 views

Getting UTC DateTime from Model attributes

The AttributeType::DateTime in model attributes saves as UTC which is great, but upon getting that attribute I receive a Craft\DateTime object with my server timezone set for it, and thus the time ...
1
vote
1answer
712 views

Update User “Field Type” for Entry in Plugin

I have a channel called "Groups", with a users field type called members for the entries. I need to be able to add/remove users to the members entry field via plugin. What I've tried is: // criteria ...
1
vote
1answer
70 views

Accessing and Manipulating a Variable

Hopefully simple variable / concatenation question: What is the best way to retrieve the url of a specific asset the name of which should be concatenated from an asset field variable and a text string?...
1
vote
1answer
216 views

Using $model->validate() with AttributeType::Url

I have a basic model defined: protected function defineAttributes() { return array( 'id' => array(AttributeType::String, 'required' => true), 'url' => ...
1
vote
1answer
354 views

Add or extend attributes (table column) to fields table

I'm trying to find a way to extend the meta fields inside a custom field definition. To illustrate: I need a min_vis def_vis and max_vis column for each field (or anytime a new one is added). ...
2
votes
1answer
137 views

Accessing the attributes of an Asset field

Specifically looking at these attributes http://d.pr/i/1ilbr I can access Alt text by {{ entry.assetHandle.first().altText }} and similarly can do {{ entry.assetHandle.first().sourceUrl }} but Source ...
5
votes
1answer
795 views

What attribute type should I set in the record or model to create a TEXT type in the database?

I am having a problem with record and model attribute types. I have a frontend user form with some textfields which require a TEXT type field in the database to hold the data. So far I have tried ...
1
vote
1answer
435 views

Is there a good way of setting a model attribute to be an instance of another model?

I have an API call to make that needs a particular format of data shown below. The person and addresses attributes are currently set as Mixed AttributeTypes and I'll need to create a manual validation ...
1
vote
0answers
149 views

Record - Mixed/String values will not be saved if attribute not required=true

I have defined string and mixed attributes for my Record/Model. 'titel' => array(AttributeType::String), 'lage' => array(AttributeType::Mixed, 'required' => true), If i try to save a record,...
2
votes
1answer
360 views

How do I validate an array model attribute against a set of possible values?

I have a need to set a property on a plugin Model that is an array of one or more valid values. I can see that I can use AttributeType::Enum and record and define a set of values but if I'm not ...
0
votes
1answer
463 views

AttributeType::String is NULL in my database

I have create a plugin to save information from my form in the front-end. I can create a row with some data. Email and Number type work well but String is NULL Have you any idea ? my controller ...
2
votes
1answer
1k views

How can I have a dynamic/virtual attribute AND have as an attribute of the Model?

Take the example of a model with a firstName and lastName. I know I can add a getFullName method to the model, and $model->fullName will run through the getter. However, I'd like the attribute to ...
6
votes
2answers
156 views

Difference between using subscript syntax and “dot” syntax when accessing attributes of a variable or advantages of usage one of them

When to use {{ variable.property }} and when to use {{ variable['property'] }} Is there a difference between these methods of accessing attributes of a variable or advantages of using one of them?