17

You need to change your input tag from: <input id="Address" type="text" name="Address" {%- if account is defined %} value="{{ account.Address}}"{% endif -%}> To: <input id="Address" type="text" name="fields[Address]" {%- if account is defined %} value="{{ account.Address}}"{% endif -%}> All custom fields input types should have a name ...


13

block.type is actually an alias for a getType() function, which returns a new MatrixBlockTypeModel object. Those will output their handle by default, which is why it's possible to compare block.type against block type handles. But MatrixBlockTypeModel also has a handle property, so this is totally possible: {{ block.type.handle }}


12

Correct, you need to use fields[customFieldName] as the input name. The following form should do it: <form method="POST"> <input type="hidden" name="action" value="commerce/cart/updateCart"> <input type="text" name="fields[myCustomField]" value="Test123"> ... <input type="submit" value="Update Custom Field"> </...


10

Actually you should be able to specify your custom field as part of the chained element criteria: {% set currentAndFutureEvents = craft.entries.section('events').eventDate('>= ' ~ now).order('eventDate DESC') %} Source: https://plus.google.com/111247306448293182882/posts/Uu6ZuTH1NBu


7

I think .after would work, but I've used this way: {% set entries = craft.entries.section('events').limit(null) %} {% for entry in entries.eventDate('>=' ~ (now.date)).order('eventDate DESC') %} {# Show entry #} {% endfor %}


6

Ok, so I've managed to get an answer to this courtesy of Brandon Kelly. It's much more simple than I thought. Firstly, you do not have to specify a relatedTo parameter the defineCriteriaAttributes(). Craft takes care of this automatically. So in order to retrieve the details of an asset in a table list view you do the following in the ...


6

craft/storage/ is used for all sorts of things, so there’s no single API for storing things in there. Mostly you would just be working with PHP’s standard IO functions like file_put_contents(). There are some handy functions in Craft’s IOHelper class too. You can get the path to the storage folder via PathService::getStoragePath(): $storagePath = craft()-&...


6

You could use the Redactor's pagebreak plugin. Check out the docs. If activated in your Redactor config, you will have the option to insert page breaks to your content, via a new “Insert Page Break” toolbar button. Now you can get the first "page" in your template: {% for entry in craft.entries.section('blog') %} <article> <h1><...


6

In Craft, all fields are stored in the craft_content table. They are otherwise independent of any field groups, layouts, sections, or anything else. PRO: This means that any element (Entry, Category, Asset, etc) can access any field. CON: This means that every element carries the weight of every field. Though if those fields are all empty, the performance ...


5

Right now that's probably the best way to do it. For Craft 2.2, I just added a static getConstants() method to BaseEnum, so you can do can do a PluginStatus::getConstants() call that will return an array with a key => value pair of the enum options and their values that should make that cleaner.


5

You could set a variable to access the products model like so: {% set product = item.purchasable.product %} and then access the fields like normal {{ product.myCustomField }} The snapshot holds the products fields as they were at the time the line item was added to the cart. So depending on how you're using the fields would dictate the method used. You ...


4

A huge boon to Craft is the ability to re-use fields across all your content – sections, categories, entry types or even users. The field groups are basically only there to make it easier for you to manage your fields in the CP, and impose no limits on where you can use any one field. Field re-use means that (at least with a little planning) the number of ...


4

MySQL has a hard coded limit of 4,096 columns per table, although that can be effectively limited by the data types of columns involved. Matrix fields get their own tables, so they don't count against the craft_content table. But yes... if you're planning on having non-Matrix fields in the 2,000 - 4,000 field range, then there's a chance you'll bump into ...


4

You could use the Preparse plugin to save the product ID part of your field in a new hidden field. Add a new "productId" Preparse field to your entry type with this code in the field's settings: {{ entry.customField|split('-')|first }} To update all existing entries, re-save them by going into Settings → Sections → Section Name and click Save. You can now ...


4

If i understand your question correct, you like to output the user data. I don't think that you need the getContent() function. But it's important, that you use the first() function. Here is your code: {% set userProfile = craft.users.id(userId).first() %} {{ userProfile.yourFieldname }} Hope it works.


4

I was close. I was correct in assuming my syntax was incorrect for setting the value of an entries field. Since an entries field is an array of elements, not just a single element, I just needed to set the value of the field as an array instead of a string. Changing $cart->setContentFromPost(['entriesFieldHandle' => $entry->id]); to $cart->...


4

When you assign element IDs to a relation field you need to pass the data in an array format. See this related answer: In a plugin, how do I save an entry with a related entry Key information in that answer: <input type="text" name="fields[customTextField]" value="My Text Data"> <input type="text" name="fields[customRelationField][]" value="101"&...


4

The database will be storing the date as seconds since 1970 (epoch) and your view on that is not localised. However, the front end date is localised for your time zone. Of this I am more sure than that the sun will rise tomorrow (thanks to a recent rise in right wing politicians).


4

It turns out the data wasn't being saved as I hadn't set a fieldLayoutId value. Now that I've figured this out, I've written a helper method to make saving any entry type much easier: public static function saveNewEntry(string $handle, array $fields) { $entryType = EntryType::find()->where(['handle' => $handle])->one(); $entry = new ...


4

With the supercool table maker you can create dynamic tables. Is this what you are looking for?


3

You’re just missing the : at the end of :notempty: in your second example. This will work: {% set params = { section: 'sectionName', customField: ':notempty:', limit: 10} %}


3

I would say you can do this yeah, it just take a little figuring out is all. Your input template could look something like: <input type="text" name="{{ name }}[title]" value="{{ value.title is defined ? value.title }}"> <input type="text" name="{{ name }}[description]" value="{{ value.description is defined ? value.description }}"> <input ...


3

That string that Craft stores is just JSON. When you try to save an array, Craft will automatically JSON-encode it, since MySQL doesn’t have an array-based data type. To get that string to be automatically decoded back into an array for you, you need to give your field type a defineContentAttribute() method that returns AttributeType::Mixed: public ...


3

I can think of a couple of options and I'll just throw them all out there. Have a separate model per partial form and each model performs its own validation. Have a single model, but have it override the rules() method and you can conditionally set what validations methods you want depending on the step you're on. Presumably, you'd want to pass in a step ...


3

Firstly I'd recommend splitting the first name and last name into seperate fields. That way in your templates it would look nicer: {{ member.firstNameField }} {{ member.lastNameField }} than having: {{ member.firstNameField }} {{ member.title }} when outputting their names. Once you have done that, in your entry type settings you can set the entry title ...


3

Just to make sure I am on the same page, you have a select field within the control panel that is populated with the prefix/title(s)? If that's the case, within your registration form, you could do something like this. Not tested, but should be close... {% set options = craft.fields.getFieldByHandle('yourFieldHandle').getFieldType.options %} {% if options|...


3

What you're probably looking for is: if ($order->signupForNewsletter->contains('joinMailingList')) { echo "I've opted in"; } else { echo 'Not matched'; }


3

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 have Craft serialize the data before it's saved to the craft_content table. Simply return AttributeType::Mixed from your FieldType class' defineContentAttribute() ...


3

You can’t change or add fields to the General Settings page, but for site wide available content Craft has this concept of Globals. See the documentation on it: https://craftcms.com/docs/globals It’s also very easy to manage user permissions for Globals, so you can allow certain user groups (besides admins) to change the meta data, somthing that (currently)...


3

Solved! {% for letter in currentUser.newsletters.options %} <input type="checkbox" value="{{ letter.value }}" name="{{ letter.value }}" id="{{ letter.value }}" {% if letter.selected == true %}checked="checked" {% endif %}/> <label for ="{{ letter.value }}">{{ letter.label }}</label> {% endfor %}


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