dynforms validation

12 views
Skip to first unread message

Barry Loper

unread,
Feb 25, 2014, 6:51:43 PM2/25/14
to toscawidge...@googlegroups.com
Before I get too crazy with custom code, I want to make sure I'm not missing / misunderstanding something. I'm using HidingCheckBox to display either an A or B set of fields. Problem is that A and B are hidden until one actually checks/unchecks the box. I'd like A to display when the Checkbox is unchecked and B when it is checked. Worse, if there is a validation error, the form reloads and all fields are hidden until the user checks then possibly unchecks the box. Even if I pass the value= to the form, and it populates the fields including the checkbox, the right things are hidden until the Checkbox is toggled. Do I need to write my own javascript to hide/unhide based on the checkbox value on document load, or am I missing something?

The form: 

class ParticipantNameForm(twd.CustomisedTableForm):
    action = lurl("/participant/save")
    submit = twf.SubmitButton()
    class child(twd.HidingTableLayout):
        label = None
        is_company = twd.HidingCheckBox(
            label="This is a Company",
            mapping={1: ['org_name', 'tax_id_num', 'org_filing_name',
                        'org_account_num'],
                     0: ['salutation', 'first_name', 'mi', 'last_name',
                         'suffix', 'birthday', 'ssn', 'filing_name',
                         'nick_name', 'spouse', 'offspring']
                     }
        )

        salutation = twf.TextField(label='Sal.',
                                validator=twc.StringLengthValidator(max=8))
        ......class def continues............

Then in the Controller:

return dict(data=part, page="participant", title="New Participant",
                    name_form=forms.ParticipantNameForm)

And the Genshi template:

<form name="name_form" method="post" py:replace="name_form.display(value=data)">
    <h3>No name form found.</h3>
</form>

Apologies if I missed some important info, but any help would be appreciated.

-Barry

Paul Johnston

unread,
Feb 26, 2014, 2:21:04 AM2/26/14
to toscawidge...@googlegroups.com
Hi,

HidingCheckBox only shows fields when checked; it doesn't do what you need. I suggest you use a HidingSingleSelectField instead. Alternatively, you could edit the source code to tw2.dynforms and add the feature you need - I expect it wouldn't be too complicated.

Paul



--
You received this message because you are subscribed to the Google Groups "ToscaWidgets-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to toscawidgets-dis...@googlegroups.com.
To post to this group, send email to toscawidge...@googlegroups.com.
Visit this group at http://groups.google.com/group/toscawidgets-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages