6 votes
Accepted

Frontend Form - Checkboxes cannot "all" be unchecked

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 ...
user avatar
  • 6,442
5 votes
Accepted

Multiple checkbox conditional

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

Retrieving Checkbox Values from Plugin

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, ...
user avatar
4 votes
Accepted

Getting checkbox options for a new entry, without having an entry

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 ...
user avatar
4 votes
Accepted

Search against a checkboxes field's options

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 ...
user avatar
  • 35.8k
4 votes
Accepted

How to populate a custom checkbox field with tag data dynamically?

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 '...
user avatar
4 votes

User registration form with checkbox field

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[...
user avatar
  • 73
3 votes

Only executing if a matrix checkbox has a specific value

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

Checking value of customer order field within Plugin

What you're probably looking for is: if ($order->signupForNewsletter->contains('joinMailingList')) { echo "I've opted in"; } else { echo 'Not matched'; }
user avatar
  • 66.4k
3 votes
Accepted

Getting Checkboxes to work on Frontend Forms

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 ...
user avatar
3 votes
Accepted

getQuery() returns only one value

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 ...
user avatar
2 votes

Getting Checkboxes to work on Frontend Forms

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 ...
user avatar
  • 6,442
2 votes

How to populate a custom checkbox field with tag data dynamically?

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 ...
user avatar
2 votes

Can't get checkboxfield values to show

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 %}, {% ...
user avatar
2 votes
Accepted

Can't get checkboxfield values to show

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 %}...
user avatar
2 votes
Accepted

Checkbox array for days of the week

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') > ...
user avatar
  • 66.4k
2 votes

Search against a checkboxes field's options

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 ...
user avatar
  • 35.8k
2 votes
Accepted

Get entries from client checked options

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 ....
user avatar
  • 3,390
2 votes

Selecting entries using a checkbox field

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. ...
user avatar
2 votes

Is it possible to convert plain text array to an unordered list?

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) <? ...
user avatar
2 votes
Accepted

Is it possible to convert plain text array to an unordered list?

Something like this should work: {% set listItems = plainTextValue|replace('/[^, a-zA-Z0-9_-]|[, ]$/s','')|split(',') %} <ul> {% for listItem in listItems %} {% if listItem|length %} ...
user avatar
2 votes
Accepted

Drop-down and checkbox in a condition

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 ...
user avatar
  • 35.8k
2 votes

Only executing if a matrix checkbox has a specific value

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 ...
user avatar
  • 3,833
2 votes
Accepted

Sum of one checkbox field

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 /...
user avatar
2 votes

getQuery() returns only one value

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 ...
user avatar
2 votes
Accepted

Filtering search with checkboxes multiple param querystring

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 ...
user avatar
  • 1,979
2 votes
Accepted

Error 'form[fieldName] : <fieldName> is invalid' while submitting multiple checkboxes

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 ...
user avatar
2 votes
Accepted

How to filter entries by multiple checkbox field types

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 ...
user avatar
  • 176
2 votes
Accepted

Sprig - Filter entries by custom field checkbox values, separate values as well as all values

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 ...
user avatar
  • 6,146
1 vote

Is it possible to allow a user choose tags in admin panel using checkboxes?

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, ...
user avatar
  • 6,442

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