Thanks for your reply. I am trying to use your advice with name-${id}
solution, but it doesn't work.

I am using following template for generating the rows for table of
radio boxes:

            <tr py:for="index, right in enumerate(rights)">
              <td>
                ${right[0]}
                <input type="hidden" name="rights-${index}" value="$
{right[0]}" />
              </td>
              <td class="na"><input type="radio" name="values-$
{index}" value="na" checked="${'checked' if right[1] is None else
None}" /></td>
              <td class="ro"><input type="radio" name="values-$
{index}" value="ro" checked="${'checked' if right[1] == 0 else None}" /
></td>
              <td class="rw"><input type="radio" name="values-$
{index}" value="rw" checked="${'checked' if right[1] else None}" /></
td>
            </tr>

I have following formencode schema for validation:

class DirectorySaveSchema(formencode.schema.Schema):
    allow_extra_fields = True
    filter_extra_fields = True
    pre_validators = [formencode.variabledecode.NestedVariables()]
    values = ForEach(validators.UnicodeString(), always_list=True)
    rights = ForEach(validators.UnicodeString(), always_list=True)

This schema I am using in @validate decorator for my @expose(d)
method:

    @expose()
    @validate(validators=DirectorySaveSchema())
    def directories_save(self, directory=None, rights=[], values=[],
**kw):
        import logging
        logger = logging.getLogger(__name__)
        logger.debug(str(kw))
        logger.debug(str(rights))
        logger.debug(str
(values))
        return dict()

But it doesn't function. I wonder why?

Any ideas?


On 25 led, 21:59, "Diez B. Roggisch" <[email protected]> wrote:
> Am 25.01.10 20:38, schrieb Martin Vejmelka:
>
>
>
> > I'd like to use multiple radio button to allow administrator select
> > rights for each user in the lis access mode (n/a, ro, rw). The part of
> > the form would look like this:
>
> >              <tr py:for="index, right in enumerate(rights)">
> >                <td>
> >                  ${right[0]}<!-- right[0] stores username which is
> > uniqe -->
> >                </td>
> >                <td class="na"><input type="radio" name="values"
> > value="na" checked="${'checked' if right[1] is None $
> >                <td class="ro"><input type="radio" name="values"
> > value="ro" checked="${'checked' if right[1] == 0 els$
> >                <td class="rw"><input type="radio" name="values"
> > value="rw" checked="${'ehecked' if right[1] else Non$
> >              </tr>
> >            </table>
>
> > I can't figure out, how to name the form field in order to get
> > "dictionary of values indexed by some index" where the value for each
> > user would be na/ro/rw. In above example I use simply name="values",
> > but than I get (of course) one big table where only one thing can be
> > selected. I could use unique name for each table row, but it's not
> > very clean and I'd like to access these values as array in TurboTears
> > 2 controllers. I have tried things like name="values[]" or name="values
> > [${right[0]}] but without any success.
>
> Use a ForAny-validator with always_list=True, and render the entries
> with a trailing number. See this post:
>
> http://www.mail-archive.com/[email protected]/msg34767.html
>
> This is done automatically done for you if you use
> ToscaWidgets/tw.forms. I strongly suggest that.
>
> Diez

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to