Announcement Announcement Module
Collapse
No announcement yet.
using checkbox with freemarker Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • using checkbox with freemarker

    anyone has a clue i can bind a single checkbox to a form object using freemarker?
    i got hold of this
    <@spring.formCheckboxes path, options, separator, attributes/>

    does this help for a single checkbox??

    thank you.

  • #2
    if there's only a single element in your options Map then it will only show a single checkbox - what problem did you have when you tried it?

    Comment


    • #3
      am very new to spring..i am not sure i have the syntax correct. i have this piece of html code which i have to bind
      <input type="checkbox" name="f_active" id="f_active" checked value="1" class="checkBox">

      i have a form.active boolean for checkbox. getting a little confused with the syntax i am sure...

      <@spring.bind "form.active" />
      <@spring.showErrors "<br>"/>
      <@spring.formCheckboxes "form.active", "checked value='1' "/>

      would that be correct? or am i geting it all wrong..especially the parameters for the checkbox?

      Comment


      • #4
        apologies for the late reply - only just noticed your post

        If you're using the Spring macros, you don't need to call <@spring.bind/> Each macro will do the binding for you.

        Your HTML example has the field name "f_active" but you're trying to bind to a field called "active" in a command object named "form". Make sure that is actually what your command object is called (the default is "command") and change the field name in the command object to be "f_active" is that's really what you want.

        You don't supply the 'checked' or the 'value="1"' to the macro - it gets calculated for you based on the value of the f_active field. In your example, the last paramaeter would need to be "checkBox" which will then output the class attribute on the checkbox itself.

        Regards,

        Comment

        Working...
        X