6

Your code is correct but you need to add another line near the top: <input type="hidden" name="fields[volunteerPositions]" value=""> From the documentation: If you are including a Checkboxes field on a front-end entry from, make sure to include a hidden input before the checkboxes, so that an empty value is submitted if no checkboxes are checked.


5

That contains test just does a smple string comparison. Try this: {% if entry.pageOptions.contains('anotheroption') or entry.pageOptions.contains('testimonials') %}


5

You can pull an array of all the options for a checkbox field by calling getOptions(): $options = $entry->storyCategories->getOptions(); Each option will be an object with three properties, label, value and selected. To get all selected options for a field, you can loop through the options and test for the selected property: $options = $entry->...


4

You can pull the field directly using craft.fields: {% set myFieldOptions = craft.fields.getFieldbyHandle('myFieldOptions') %} The options will be available under the field's settings.options property. Each option will have attributes for value and label: {% for option in myFieldOptions.settings.options %} {{ option.label }} {{ option.value }} {% ...


4

Checkboxes / multiselect fields store to the database in a very query unfriendly way. That's why I would really recommend to use categories, tags, lightswitches instead, if you intend to query against these fields' values. Here's what you'd have to do to search for entries with selected checkboxes field types' options. You basically have to get all relevant ...


4

I don't have enough reputation to post this as a comment, but this should help you pull the data on the front end with the LJ Dynamic Fields plugin. Install the LJ Dynamic Fields plugin. Create a 'Checkboxes (dynamic)' field with the following code: {% for tag in craft.tags %} { "value":"{{ tag.id }}" , "label":"{{ tag }}" } {% if not loop.last %},{%...


4

Just in case anyone else has this issue i got it working with these modifications. I think the hidden field was required for the possibility of null values. <input type="hidden" name="fields[myCustomField]" value="no"> It also required the extra [] brackets after the field name in the checkbox option (as checkbox fields are an array). name="fields[...


3

{% if block.checkboxFieldHandle.contains('someChkbxValue') %} <p>Executed!</p> {% endif %} actual for Craft v2.x and v3.x


3

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


3

The first loop you're using loops over entry.gistCategories.options, which contains all the options available. However, in the second loop (when entry.gistCategories|length !== 0), you're only looping over the options that have been selected. Try this: {% if entry.gistCategories | length == 0 %} <ul> {% for option in entry.gistCategories....


3

This question is not really Craft related. Since you just don't send a valid request. You can't send one key multiple times unless you do it in an array. The php $_GET is a simple array with all your values and you overwrite them again and again. https://stackoverflow.com/questions/5098397/how-to-pass-an-array-in-get-in-php


2

Since the form was already submitted, your code is only looping through the checkboxes that were checked. Just add .options to your second for block like you have above: {% for checkboxOption in entry.gistCategories.options %} That'll loop through all of 'em, checked or not.


2

Not tested. But it would seem to me that you could use a tags field on the backend, and a checkbox field on the front-end (built dynamically from the tags). To submit the data you could either: format the data on the front-end via javascript before form submission, or submit to a custom plugin controller that converts the checkbox data format to the expected ...


2

If you want a comma-separated list of selected options, try this. {% for option in offer.offerMinimumPrice.options|filter(v => v.selected) %} {{ option.label }}{% if loop.last==false %}, {% endif %} {% endfor %} for provides a loop object that provides many useful variables. filter can be used to filter down items in a list or map using an arrow ...


2

The problem was that I used this code within an entry, so I had to use the tag of that entry (offer) instead of entry. The code that works now is: {% for option in offer.offerMinimumPrice.options %} {% if option.selected %} {{ option }} {% endif %} {% endfor %}


2

This should do what you're looking for: {% set closed = true %} {% for dayOfWeek in theCenter.openWeekDay %} {% if 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') > theCenter.openTime|date('Hi') and 'now'|date('Hi', 'America/Denver') < theCenter.closeTime|date('Hi') %} {% set closed = false %} {% endif %} {% ...


2

Have a look at the Checkbox field plugin. It provides a field type that looks like the default Checkboxes field, but stores a boolean value to the database (similar to the Lightswitch field), so you can use a custom field parameter in your criteria model. {% set entries = craft.entries.myCheckbox(1).myOtherCheckbox(0) %}


2

The most straightforward way would be to use a Categories field. The value that a Categories field returns to the template is an ElementCriteriaModel, which fits perfectly as a value for the .relatedTo parameter. So you could do something like: {% set featuredEntries = craft.entries.relatedTo( entry.selectedCategories ) %} The only circumstance where I ...


2

Reply via Brandon: A single field does probably make more sense here, as you have it. You're close to getting it working, but your syntax for filtering categories based on craft.locale is wrong. Checkboxes fields store the selected option values as JSON, so if you check your craft_content table you will find values like ["option_1","option_2","option_3"] ...


2

Is the data a pseudo-syntax, or is it JSON? If the answer is JSON, then the following may be a more robust solution: Create a barebones plugin (craft/plugins/helpers/HelpersPlugin.php) <? namespace Craft; class HelpersPlugin extends BasePlugin { public function getName() { return Craft::t('Helpers'); } public function getVersion() { ...


2

Something like this should work: {% set listItems = plainTextValue|replace('/[^, a-zA-Z0-9_-]|[, ]$/s','')|split(',') %} <ul> {% for listItem in listItems %} {% if listItem|length %} <li>{{ listItem|trim }}</li> {% endif %} {% endfor %} </ul> What the above does is to first use the replace filter to remove any ...


2

A checkboxes field returns an array of models, that you can inspect using {{ dump(sourceCountry) }} in your loop. The model has a __toString method that outputs the checkbox value when you output the model using {{ sourceCountry }}. This magic method doesn’t do its thing when you use the model in a comparison operator, so you are currently comparing a model ...


2

It looks as though you have the following line wrong: {% for block in photos if block.imageLocation.contains('featured') %} You will need to use the field name you're using to filter the Matrix block in place of contains. The following line will only loop through block with the imageLocation field set to "featured". {% for block in photos.imageLocation('...


2

What you could try is putting the "if statement" as a condition in the for loop like this: {% for premiereItem in entry.kompositonsart if premiereItem.value == 'ua' %} //the checkbox loop starts // only return checked value with 'ua' {{ countPremiere }} {% endfor %} I'm not really sure what you are asking but if my thoughts are right this should do ...


2

Using the corrected checkbox name name=checkValue[] the submitted values ?checkValue%5B%5D=12345&checkValue%5B%5D=23456&checkValue%5B%5D=34567 are converted to an array. The array values can now be accessed using {% set checkVals = craft.request.getQuery('checkValue') %} {{ checkVals[1] }} {# outputs 23456 #} or {% for cVal in checkVals %} {...


2

You can do this by getting all the params in the url that have the same name and joining them into a single string which you can use in your Twig template. Note this code is untested but is based on something I've recently done. This example only uses categories but it's possible to expand it to search custom fields and/or add a free text search too. {# ...


2

I'm not sure if it can make a difference, but you should try to remove the white space between the two array in the name attribute. Then I think you may have to format the date value with the date filter. <label> <input :class="{ error: error['formDate'] }" type="checkbox" name="fields[formDate][]" value="{{ date.value|date('Y-m-d') }}">{{ ...


2

Apologies if I’ve misunderstood your question and over-simplified things, but wouldn’t the search() method give you precisely what you need? As in: {% set valsToFind = "field_photoColor:red OR field_photoColor:green OR field_photoSubject:animal OR field_photoSize:small" %} {% set galleries = craft.entries.section("gallery").search(...


2

My suggestion would be to give the Select All Values checkbox a unique name. That way, you can easily detect whether it was selected or not. You should also break dropdown_field out into 2 variables to avoid confusion. {% set select_all_values = select_all_values ?? false {% set dropdown_field_options = ['dropdown_value_1', 'dropdown_value_2', '...


1

Any reason why you'd choose tags over categories? Categories seem to be more of what you're describing: Eventually, every single required tag will be created at some point. And since Craft 2.5, authors can easily create categories right in the Entry screen as well as pick the category they want if it's already created. No manual typing required if it ...


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