0

I do not understand why the examples in the manual not work. Here in the forum I do not see the ricgt code as well. I feel stupid.

I have a field, defined as checkboxes, values populated by other field. (I do not know how many values my client fills in there)

Please, how do I code this in my form? In the form, when coding {MYFIELDNAME} it just puts out all the values, no checkboxes there. This code does not work either:

{options:MYFIELDNAME}
<label class="checkbox">
<input type="checkbox" id="{MYFIELDNAME}" name="{MYFIELDNAME}[]" value="{option_value}"{checked}> {option_value}
</label>
{/options:MYFIELDNAME} 
0

Second time lucky!

I believe that Hansl was actually trying to have a check box field populate CartThrob item options.

That can be achieved by replacing his code with...

<select name="item_options[maat]">
  {maat}
    <option value="{item}">{item}</option>
  {/maat}
</select>
1

Don't feel stupid! You were very close.

The only thing you need to change is the ID and name attributes don't need the {}'s around them.

It should work if you make it...

{options:MYFIELDNAME}
    <label class="checkbox">
        <input type="checkbox" id="MYFIELDNAME" name="MYFIELDNAME[]" value="{option_value}"{checked}> {option_value}
    </label>
{/options:MYFIELDNAME} 
5
  • I am so sorry, that code did not output OK. I tried also with closing the input tag, no luck. – Hansl Mar 2 '14 at 19:43
  • Input tags are self closing, so no need to close that with</input>. what is your field name actually called? – Mutual Mar 2 '14 at 19:48
  • Complex commenting system, not used to, sorry. this i my tag with original field name {options:maat} <label class="checkbox"> <input type="checkbox" id="maat" name="maat[]" value="{option_value}"{checked}> {option_value} /> </label> {/options:maat} – Hansl Mar 2 '14 at 19:51
  • That '/>' is definitely superfluous so should be removed. Could you email me login to the control panel to webdesign@andief.com and I will take a look into it for you and report back here with the answer for everyone else. – Mutual Mar 2 '14 at 19:53
  • I do appreciate this VERY much. I have send you a mail to the address I found on your site. – Hansl Mar 2 '14 at 20:15

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.