Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Usage of #process is the key.
Comment | File | Size | Author |
---|---|---|---|
#12 | checkbox_validate-HEAD.form-api.12.patch | 3.25 KB | sun |
#10 | checkbox_validate-HEAD.form-api.patch | 3.79 KB | sun |
#9 | checkbox_validate.form-api.9.patch | 3.37 KB | sun |
#4 | checkbox_validate-HEAD_425096_cck.patch | 3.62 KB | dboulet |
#3 | checkbox_validate_process.patch | 3.01 KB | jcmarco |
Comments
Comment #1
sunbump
Comment #2
Robert Castelo CreditAttribution: Robert Castelo commentedSun 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.
Comment #3
jcmarco CreditAttribution: jcmarco commentedProbably 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.
Comment #4
dboulet CreditAttribution: dboulet commentedNew patch adds CCK field support.
Comment #5
jcmarco CreditAttribution: jcmarco commentedWith 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.
Comment #6
mafioso CreditAttribution: mafioso commentedHi 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?
Comment #7
mafioso CreditAttribution: mafioso commentedI'm an idiot.
i didn't configure my smtp support correctly.
it works now. thanks for the patch!
Comment #8
goldoak jp CreditAttribution: goldoak jp commentedIs 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.
Comment #9
sun@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.
Comment #10
sunSorry, 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.
Comment #11
dboulet CreditAttribution: dboulet commented@sun, yes, CCK changed since I submitted my patch, so the changes I brought aren't needed anymore.
Comment #12
sunAfter reviewing CCK's option widgets code, the special-casing indeed seems to be obsolete.
Hence, this patch is 100% sufficient.
Comment #13
stBorchertTested the patch in #12 and it works as expected. Thanks!
RTBC from me (can't change status, because it already is RTBC ;) ).
Comment #14
joeytheman CreditAttribution: joeytheman commentedis this going to be committed?
Comment #15
Robert Castelo CreditAttribution: Robert Castelo commentedI'll evaluate it as soon as I can this week.
Apologies for the delay, this quarter is busiest time of the year for me.
Comment #16
dafederPatch #12 worked great for me against 6.x-1.1!
Comment #17
sunPeople in IRC keep on pointing to this patch to make the module actually work...
Comment #18
Robert Castelo CreditAttribution: Robert Castelo commentedYeah, apologies for the delay, I'll get on to it tomorrow evening.
Comment #19
Robert Castelo CreditAttribution: Robert Castelo commentedCommitted as 6.x-2.0
Thanks to sun, jcmarco, dboulet for their work.
Do we need a Drupal 5 version?
Comment #20
sunD5? Don't think so.
After removing the following from the .info file:
...the new code could be released.
Comment #22
maverick14 CreditAttribution: maverick14 commentedThis 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?
Comment #23
dboulet CreditAttribution: dboulet commented@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.