Skip to main content
6 votes

Solution for Matrix-within-Matrix (or More Robust Table Fields)

This question was asked prior to the release of the Neo plugin/field type. I think this would offer a better approach than the SuperTable (which was/is still awesome), just because I think it's easier ...
Ian DeRanieri's user avatar
6 votes
Accepted

Why won't the Import plugin accept this JSON string?

You're close! The method that Lindsey recommends should work with the following method of adding content to a field: $entry->getContent()->setAttributes(array( 'tableFieldHandle' => ...
Steve Rowling's user avatar
5 votes

How to set field values for the table field type in Craft 3

I figured this out. The table field is expecting JSON: $entry = new Entry(); $entry->sectionId = 1; $entry->typeId = 1; $entry->title = $title; $entry->setFieldValues([ "field_handle" =&...
David Jones'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
Accepted

Adding Columns to a table

With the supercool table maker you can create dynamic tables. Is this what you are looking for?
Robin Schambach's user avatar
3 votes

Feed Me: How to format CSV data for a table field

You can create a feed-me.php file under your /config directory, then you can configure the data delimiter: <?php return [ '*' => [ 'pluginName' => 'Feed Me', '...
Cryptomothy's user avatar
3 votes
Accepted

Feed Me: How to format JSON for a table field?

You can do this a number of ways, and essentially just need an array-like structure to represent the rows. "Table": [ { "one": "Option1", "two": "Option2" }, { "one": "Option3", ...
crawf's user avatar
  • 3,562
3 votes

Saving to table field via plugin

The answer on the previous question is a little bit off - you do not want to use json_encode to save the field. Just use the actual array: $tableValue = [ [ "col1": "Product #1", "col2": "5"...
Dan Ott's user avatar
  • 306
3 votes
Accepted

How do I prevent empty table rows from being created when a front end form is submitted?

I figured out a solution. When I looked in the database I could see {"col1":"","col2":""} in the content even though the user didn't enter any content in the front end text form field. I couldn't ...
Lori's user avatar
  • 866
3 votes
Accepted

Limit rows using Table

I have never tried it on a table field, but you could try: {% for row in block.example.limit('1').order('RAND()') %} {{ row.examplerow }} {% endfor %} OK, above will not work. I went back on my ...
AbbeyDesign's user avatar
  • 1,527
3 votes
Accepted

Creating a editable table with Element Select in column

For my specific case, Super Table was the answer. You can also check Neo
Jorge Anzola's user avatar
2 votes
Accepted

Count table field values in certain section

You can get the total amount of rows like this: {% set totalcount = 0 %} {% for entry in entries %} {% set totalcount = totalcount + entry.artikelnummer|length %} {% endfor %} Edit In the ...
Jan_dh's user avatar
  • 858
2 votes
Accepted

Is it possible to search an entry for specific table content

I don't believe this is possible using the native search functionality. You can search for a specific value within a table field using: {% set results = craft.entries.search('tableField:"ID"') %} ...
Steve Rowling's user avatar
2 votes

Adding Columns to a table

I used the method described here: "A User-Friendly Table Field" http://www.drivesimplicity.com/blog/a-user-friendly-table-field -- instruct the user to leave columns that he/she doesn't want blank and ...
userAW's user avatar
  • 176
2 votes

Conditionally show table column headings

I just came across this challenge too and ended up solving it slightly differently: {% set columnsToShow = [] %} {% set tableField = craft.app.fields.getFieldByHandle('tableFieldHandle') %} {% for ...
James Smith's user avatar
  • 5,344
2 votes
Accepted

How to relate a long survey to a user and later query by values

When you're dealing with that many fields it's definitely a non-trivial undertaking but Craft does have all the tools you need to pull it off. Your plan B is probably the most solid option. Make a ...
RitterKnight's user avatar
  • 6,582
2 votes
Accepted

Check if a table field’s column has a value

You were close... Chaning this: {% if row.url == 0 %} to this: {% if row.url|length %} should do it for you.
Brad Bell's user avatar
  • 67.5k
2 votes

table field - make one culumn translatable, other common for all languages

If there’s a predetermined set of feature names, then you could translate them using static message translations. {% for row in entry.myTableField %} <dt>{{ row.featureName|t }}</dt> &...
Brandon Kelly's user avatar
2 votes

Query Craft CMS Table Field for exact values

Yeah because the data is stored as a JSON blob, I'm not sure this is going to be possible without retrieving all the data, parsing the JSON, then doing the exact match search via PHP, and then ...
andrew.welch's user avatar
  • 11.6k
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
Accepted

Use own/custom field inside Craft Table

I think you just can't: allowed field types seem to be hardcoded in craft\fields\Table::getSettingsHtml(). See https://github.com/craftcms/cms/blob/develop/src/fields/Table.php#L215 for details. You ...
nstCactus's user avatar
  • 1,149
2 votes
Accepted

Saving data in a table field in a matrix field via entry form

The easiest way to figure this out is to edit an entry with these fields in the CP and monitor the network request that is made on save (or when saving a draft). Here's what I see in my browser dev ...
Ben Croker's user avatar
  • 7,536
2 votes
Accepted

Add rows to table field

You shouldn't JSON-encode the table field values; Craft handles that internally. Simply give it a multi-dimensional array. The below would save one row with two columns to the table field itemEvents, ...
Mats Mikkel Rummelhoff's user avatar
2 votes
Accepted

Replace the value of a table cell (inside a Matrix field)

You're setting the field value and saving the matrix block once for every row in your table, you only need to do that once. The actual problem is that you're merging a new array into $table for every ...
MoritzLost's user avatar
  • 11.5k
1 vote

List elements grouped by multiple dates

You could loop through all your events, and create a date-keyed hash with the ids of the entries - assuming your (e.g {% set saleDays = {} %} {% for entry in events %} {% for row in ...
Nick's user avatar
  • 146
1 vote

order by Table Number Field

orderBy() should do the trick. The docs show following syntax: .orderBy('elements.dateCreated asc') Maybe something like: {% set entriesList = craft.entries.section('parks') .relatedTo(entry.Line....
phaetons's user avatar
  • 705
1 vote
Accepted

Query Craft CMS Table Field for exact values

If you're looking to see if the search term matches any row/column value in the field, then it should work: myTableFieldHandle::SKU3 If you are looking to find the exact row/column that matched, you'...
Brad Bell's user avatar
  • 67.5k
1 vote

Loop over table field in Element API plugin

A table field contains a simple array, you can serialize and unserialize it as it is. So there is no custom action required by your side. Just use it in PHP like every other textual field
Robin Schambach's user avatar
1 vote

I have a table type field that I need to access to rows individually

{{ entry.myTableField[1] }} and {{ entry.myTableField[6] }} You also might want to check to make sure they exist. {% if entry.myTableField[1] is defined and entry.myTableField[1] is not empty %} ...
Clark Nelson's user avatar
1 vote

Can you store a table field within a matrix field?

I figured it out. You can do it. Here is my example. {% for block in mainNavigation.navigationLink %} <a class="navbar-item {{ block.className }}" href="{{ block.linkUrl }}"> ...
Danielle Frappier's user avatar

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