Forums | Mahara Community

Developers /
Pieforms Question


anonymous profile picture
Account deleted
Posts: 117

04 September 2009, 16:39

I have a form where a checkbox disables the other checkboxes in the group to ensure that only that checkbox is submitted.  It's used to specify access permissions for a new section I'm working on.  It works fine unless the user submits the form without filling in a required field.  If that happens, all the checkboxes are enabled again. 

How can I make sure those checkboxes remain disabled when errors occur without using a Javascript function with onload?  For example, if checkbox a is set, then checkbox b should be remain disabled if the form fails validation.  Does that make sense?

Thanks

anonymous profile picture
Account deleted
Posts: 1643

07 September 2009, 7:58

Hm, interesting question. I'm guessing you're using 'defaultvalue' => true for the checkboxes, which is right. Technically, disabling the checkbox and submitting the form (with a validation error elsewhere) should result in the checkbox not being checked. Maybe that isn't happening though - checkboxes aren't sent through when they're unchecked, that could be causing an issue.

Can you try reducing the form to a simple example that demonstrates the behaviour? I'll have a look into it if you find that with a simple pieform it's showing undesirable behaviour. 

anonymous profile picture
Account deleted
Posts: 117

10 September 2009, 2:02

The element was enabled when pieforms rendered it originally, but then was disabled via Javascript based on what the user selected.  Then if the user submitted the form and it failed validation, the disabled checkboxes were returned to an enabled status when they should remain disabled.  I was just wondering if there was a way to specify in the validation process to disable the checkboxes?

Not a big deal, though, because I just used jQuery to disable the appropriate checkboxes if the form failed to pass validation.

anonymous profile picture
Account deleted
Posts: 1643

10 September 2009, 16:55

Well pieforms should do that for you automatically, is what I'm saying Wink. And I was pretty sure it did, but it's hard to say without knowing a bit more, like your form definition.
4 results