Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Priority: Normal » Critical

bump

Robert Castelo’s picture

Sun thanks for the patch - could you please explain what issue this fixes?

Your patch is quite an extensive re-write so it's hard to know what specific coding error it's correcting or what bug to test against to see if it fixes the problem.

jcmarco’s picture

Version: 5.x-1.x-dev » 6.x-1.1
Assigned: sun » Unassigned
FileSize
1.24 KB
3.01 KB

Probably what sun is doing but not explaining is a code cleaning and re-styling and
the most important is to point that using fapi hook_elements is possible to focus the action in just the checkbox.

This way we are not doing a form_alter with scanning of all elements every time. So there should be a performance boost.

Applying this approach to the module and D6, I got this version that avoid using the theme function (with no content) the form_alter and the scanning function.
I have tested it in the same situation that was running the previous version and now it is still working fine, but probably with best performance results.

As the hook it altering the checkbox element wherever it is, it could work in any situation so it is possible that could fixed some of the other issues open here.
Also applying this process to any other form element that could need this testing should work in the same way but it would need to add the form element in the hook_elements.

I add the patch form version d6-1.1 and the full module to ease the testing of this new version.

dboulet’s picture

New patch adds CCK field support.

jcmarco’s picture

With the next possible backporting to D6 of the core bug: http://drupal.org/node/179932#comment-1959520
and with cck optionwidgets module patch: #567168: Checkbox required not defined for on/off widgets

this module and any issue with required checkboxes will finish,

I have tested legal without checkbox validate and core backporting patch and everything works fine,
with the backporting core patch and cck optionwidgets any cck required on/off field works fine as well.

mafioso’s picture

Hi all,

I have a CCK form, with some required fields and a required checkbox as agreement.

after applied #4 patch my checkbox has a required sign.
By submitting the empty forms, i got following result:

- Unchecked checkbox: the form cannot be submitted with error messages that the fields are required, including the checkbox. Thats good.
but
- Checked checkbox: it comes to WSOD! no validation at all.

i already tried to turn off page caching etc. but it didn't help.

any advise?

mafioso’s picture

I'm an idiot.

i didn't configure my smtp support correctly.

it works now. thanks for the patch!

goldoak jp’s picture

Is there a patch file for version 5.x-1.0?
Or is it possible to use a patched version 6 checkbox_validate.module file on a D5 site?

Using D5.21 with CCK 5.x-1.10 and the checkbox_validate seems to have no effect.

Required single checkbox field is still not validated (node can be submitted with box unchecked) and no required field red star appears next to field on node edit page.

Checkbox is for terms agreement that is required to submit node.

Thanks for any help or advice.

sun’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
3.37 KB

@jcmarco: Nicely done! Even more beautiful than my initial 5.x patch :)

Fixed a couple of smaller nitpicks, but no major changes. This is more than ready to fly.

sun’s picture

Sorry, the additional changes for CCK support (I guess by dboulet) are breaking the element validation altogether.

Attached is a revised patch, tested for regular checkboxes (like Legal module), but didn't test CCK option widgets.

dboulet’s picture

@sun, yes, CCK changed since I submitted my patch, so the changes I brought aren't needed anymore.

sun’s picture

After reviewing CCK's option widgets code, the special-casing indeed seems to be obsolete.

Hence, this patch is 100% sufficient.

stBorchert’s picture

Tested the patch in #12 and it works as expected. Thanks!

RTBC from me (can't change status, because it already is RTBC ;) ).

joeytheman’s picture

is this going to be committed?

Robert Castelo’s picture

I'll evaluate it as soon as I can this week.

Apologies for the delay, this quarter is busiest time of the year for me.

dafeder’s picture

Patch #12 worked great for me against 6.x-1.1!

sun’s picture

People in IRC keep on pointing to this patch to make the module actually work...

Robert Castelo’s picture

Yeah, apologies for the delay, I'll get on to it tomorrow evening.

Robert Castelo’s picture

Status: Reviewed & tested by the community » Fixed

Committed as 6.x-2.0

Thanks to sun, jcmarco, dboulet for their work.

Do we need a Drupal 5 version?

sun’s picture

D5? Don't think so.

After removing the following from the .info file:




; Information added by drupal.org packaging script on 2008-05-29
version = "6.x-1.1"
core = "6.x"
project = "checkbox_validate"
datestamp = "1212071414"

...the new code could be released.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

maverick14’s picture

Status: Closed (fixed) » Needs work

This patch (or at least the new release) causes required checkboxes to break. When submitting a form for a node type that has a required checkbox field, it gives an error " field is required". No field name is included.

The required fields are unchecked in the form you get after validation fails.

Perhaps this should be a new ticket?

dboulet’s picture

Status: Needs work » Closed (fixed)

@maverick14, a lot of people have used this patch without problems. Please open a new issue, and we can figure out what's causing your bug there.