Forum OpenACS Development: Spellchecker: add-on to form-builder / ad_form

Collapse
Posted by Ola Hansson on
FYI, I am working on integrating a spellchecking facility into the form builder/ad_form which is going to use aspell/ispell and be based on (3.x) work done by Jin Choi and Eve Anderson from aD.

I hope to have this working within a few days or so if all goes well ...

My current idea (but I'm open to other suggestions) is to add some switches to ad_form; "-spellcheck_template foo" and "-spellcheck_label {Check Spelling}" (plus a "-submit_label {Blah}" and possibly a "-confirm_label {Confirm Forum Posting}" while I'm at it - but that is unrelated to spellchecking). Even though the spellcheck_template (which takes care of all the spellchecking) in a way permitts confirmation of the submitted text(s), I think we should be able to specify a confirm_template at the same time as spellchecking is specified, and that it should jump in after you're happy with the spelling (if indicated by the script, that is).

I am envisioning it something like this:


set check [parameter::get_from_package_key -package_key acs-kernel \
               -parameter SpellcheckFormP -default true]


set all_widgets {}
lappend all_widgets \
    [list email_to:text(text) {label "To"} {html {size 30}}] \
    [list email_subject:text(text),spellcheck($check) {label "Subject"} {html {size 40}}] \
    [list email_body:text(textarea),spellcheck($check) {label "Body"} {html {rows 10 cols 50}}]


ad_form -name spell \
    -mode edit \
    -cancel_url / \
    -cancel_label "Get outta here" \
    -confirm_template confirm \
    -spellcheck_template spellcheck \
    -submit_label "Submit" \
    -form $all_widgets \
    -on_submit {

    # send email

}

From the developer/admin perspective:

Many elements can be spellchecked (I'm hoping) but not all have to be. The developer can choose only some of the text/textarea elements as s/he sees fit. The site administrator can enable/disable spellchecking on a whole site via a kernel parameter (if the developer uses the technique showed above when setting vars).

From the user perspective:

The user faces a big form - now, if the developer has specified spellchecking on one text field and on one textarea, say, and has also specified a spellcheck_template that is working, the user will not just see a single "OK" submit button but will also see a "Check Spelling" button (and maybe also a "Cancel" button which will be the button farthest to the right). When the user hits the spell button s/he is sent off to the spellcheck_template and, after eventual spelling correction, sent back again (or to the confirm_template) ...

I think it would be possible to make this feature available to the form builder (and not only to ad_form) or that it is at least something to strive towards.

If you have comments or suggestions, I sure want to hear them now 😊

/Ola