Properly use Form API

sun - April 6, 2009 - 11:28
Project:Checkbox Validate
Version:6.x-1.1
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review
Description

Usage of #process is the key.

AttachmentSize
checkbox_validate.process.patch2.94 KB

#1

sun - May 2, 2009 - 19:28
Priority:normal» critical

bump

#2

Robert Castelo - May 3, 2009 - 10:18

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.

#3

jcmarco - May 27, 2009 - 13:05
Version:5.x-1.x-dev» 6.x-1.1
Assigned to:sun» Anonymous

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.

AttachmentSize
checkbox_validate_process.patch 3.01 KB
checkbox_validate.module.txt 1.24 KB

#4

dboulet - July 9, 2009 - 18:33

New patch adds CCK field support.

AttachmentSize
checkbox_validate-HEAD_425096_cck.patch 3.62 KB

#5

jcmarco - September 3, 2009 - 11:31

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.

 
 

Drupal is a registered trademark of Dries Buytaert.