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 ...
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[...
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 ...
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
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';
}
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 ...
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 %}, {% ...
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
/...
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 ...
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 ...
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 ...
2
votes
Accepted
what is the correct way to programmatically set checkboxes (MultiOptionsFieldData) in a migration? (solved)
Sleeping on it (and peeking at the db) provided a solution, with even simpler code:
$entries = \craft\elements\Entry::find()
->section('sectionProduct')
->all();
foreach($entries as $entry) ...
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 ...
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 ...
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 ...
1
vote
Accepted
How can I query entries related to another section’s entries having specific Matrix checkbox field values?
You can do it, but you’ll need to break it into a few steps:
Get the Matrix blocks having the desired checked size values.
Get the IDs of the Things entries that own those Matrix blocks.
Get the ...
1
vote
How to filter entries by multiple checkbox field types
I think this will get you there.
{% set galleries = craft.entries
.section("gallery")
.where([
'or',
{'field_photoColor' : 'red' },
{'field_photoColor' : '...
1
vote
Accepted
Ajax request returns code instead of result of the query (solved)
The path to the ajax file was wrong. I had it as:
$.ajax("templates/ajax?search=" + value, {
when it should have been
$.ajax("ajax?search=" + value, {
1
vote
Freeform conditionals
The solution is:
{% if "itching" in submission.symptomCheckerSymptoms.value %}
{% endif %}
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,...
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="...
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->...
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 ...
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 ...
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.
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/...
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]?
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 ...
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, ...
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 = ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
checkboxes × 44templating × 6
search × 6
matrix × 5
form × 4
filter × 4
craft3 × 3
entries × 3
frontend-form × 3
drop-down × 3
plugin-development × 2
categories × 2
control-panel × 2
localization × 2
entry × 2
field × 2
plugin-freeform × 2
tags × 2
entries-field × 2
frontend × 2
querystring × 2
assets × 1
plugin-craftcommerce × 1
users × 1
elementcriteriamodel × 1