Skip to main content
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 ...
RitterKnight's user avatar
  • 6,582
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[...
Matt B's user avatar
  • 73
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 ...
Robin Schambach's user avatar
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
Nikolay Bronskiy's 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'; }
Brad Bell's user avatar
  • 67.5k
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 ....
Michael Rog's user avatar
  • 3,420
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. ...
Rob Hodges's 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) <? ...
August Miller's 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 %} ...
Mats Mikkel Rummelhoff's user avatar
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 ...
Luke Pearce's user avatar
  • 3,863
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 %}, {% ...
Critical Mash's user avatar
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 /...
Justin Dekkers's 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 ...
foamcow's user avatar
  • 2,029
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 ...
carlcs's user avatar
  • 36.3k
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 ...
Philip Jones's user avatar
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 ...
Elodie Grondin's 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 ...
mitrol's user avatar
  • 262
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 ...
Ben Croker's user avatar
  • 7,536
1 vote

Freeform Checkbox Group Field only returns one value

Ok, Solspace support cam through via email with the answer... Put square brackets after the field name! Simple :) <input type="checkbox" name="MyFieldName[]" value="Item1"> <input type="...
Martin's user avatar
  • 1,203
1 vote

How do I access the checkbox field column value as a PHP array?

Another option for getting the string values as an array after typecasting the MultiOptionsFieldData object as an array: $values = ArrayHelper::getColumn(ArrayHelper::toArray( (array) $entry->...
Benjamin Kohl's user avatar
1 vote
Accepted

How do I access the checkbox field column value as a PHP array?

MultiOptionsFieldData extends PHP's ArrayObject class. You could get the values from it by casting it to an array like so: $results = (array)$mofd; That would give you an array of OptionData ...
Brad Bell's user avatar
  • 67.5k
1 vote
Accepted

Convert checkbox values from an array to a string

If you have access to jQuery in your project, you can do this. Change the name of your checkboxes so craft doesn't look at them when the form gets posted and have a hidden input (named inline with ...
Oli's user avatar
  • 7,495
1 vote

Convert checkbox values from an array to a string

If you need to do this in a twig template, the join filter will do the job. Use {{ yourCheckboxesValues|join(', ') }} to print something like that : value1, value2, value3.
Maxime Lafrenière's user avatar
1 vote

How to output 'selected' checkbox labels within a matrix

You'd use the checkbox fields much the same way they would be used if they were added directly to the entry and not in the matrix field. Assuming you've got a basic matrix field structure (using if/...
Jalen Davenport's user avatar
  • 3,045
1 vote

Entry Form: Populate checkbox list from another entry and save options in entry

Could this be a reserved word? Generally I access fields using entry.registeredOccurances is there a reason you are using fields[registeredOccurances] and entry[dateFieldHandle]?
Clark Nelson's user avatar
1 vote

Sprout Forms: Populate checkbox field options with entry data

The best way to debug a form field using custom HTML is to output the field you want via the default displayForm tag and copy the code from there as a starting point: {# Output your checkboxes field ...
Ben Parizek's user avatar
  • 13.5k
1 vote

Freeform conditionals

The solution is: {% if "itching" in submission.symptomCheckerSymptoms.value %} {% endif %}
Mark H.'s user avatar
  • 401
1 vote
Accepted

Searching on multiple checkboxes

Updating answer as question was updated As I see it, you want to find any and all entries where the field weken2017 has either the value 42 or 43. Assuming that I have understood this much correctly,...
Fuglsetrampen's user avatar
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, ...
RitterKnight's user avatar
  • 6,582
1 vote
Accepted

Only executing if a matrix checkbox has a specific value

I've managed to get things working but I'm not sure if there is a better way of doing this. Any feedback is welcome. Here's the new code. {# Grab all the photo entries #} {% set photos = ...
Rheal Poirier's user avatar

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