2

I have multiple checkboxs in a form

<input type="checkbox" name="Classification[]" value="Hub Zone">Hub Zone
<input type="checkbox" name="Classification[]" value="Not Applicable">Not 

After submit Get info is:

 'Classification' => 
  array (
    0 => 'Hub',
    1 => 'Not Applicable',
  ),

and I get error : array to string conversion on below code

 'Classification'  => array(AttributeType::Mixed, 'required' => true, 'label' => 'Classification')

stack Trace:

PHP notice
Array to string conversion

/home/www/html/www3/craft/storage/runtime/compiled_templates/3d/3df3f71b6051f05e907988ee087f2136f9ad04870a88d4a66539df50db139f6d.php(39)

27         }
28         // line 6
29         if ((array_key_exists("fields", $context) && twig_length_filter($this->env, (isset($context["fields"]) ? $context["fields"] : $this->getContext($context, "fields"))))) {
30             // line 7
31             echo "    ";
32             $context['_parent'] = $context;
33             $context['_seq'] = twig_ensure_traversable((isset($context["fields"]) ? $context["fields"] : $this->getContext($context, "fields")));
34             foreach ($context['_seq'] as $context["_key"] => $context["field"]) {
35                 // line 8
36                 echo "        ";
37                 echo twig_escape_filter($this->env, $this->getAttribute($context["field"], "label", array()), "html", null, true);
38                 echo ": ";
39                 echo twig_escape_filter($this->env, $this->getAttribute($context["field"], "value", array()), "html", null, true);
40                 echo "
41 
42     ";
43             }
44             $_parent = $context['_parent'];
45             unset($context['_seq'], $context['_iterated'], $context['_key'], $context['field'], $context['_parent'], $context['loop']);
46             $context = array_intersect_key($context, $_parent) + $_parent;
47         }
48         // line 12
49         if ((array_key_exists("footer", $context) && twig_length_filter($this->env, (isset($context["footer"]) ? $context["footer"] : $this->getContext($context, "footer"))))) {
50             // line 13
51             echo "
1

I think your checkboxes need to be as follows:

<input type="checkbox" name="fields[Classification][]" value="Hub Zone">Hub Zone
<input type="checkbox" name="fields[Classification][]" value="Not Applicable">Not 
  • I cannot get submission value back when I added fileds[]. – xyray Sep 15 '16 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.