Forum OpenACS Development: Re: losing data from richtext after ad_form validation

Collapse
Posted by Gustaf Neumann on
Actually, i was able to reproduce the behavior with and without the display mode. It seems, that one needs to refresh the field on validation errors. For example in the cases where xowiki uses ad_form, this does not seem to be necessary. However, the example below should be sufficiently simple to be adapted for other needs.

best regards
-gustaf neumann

ad_page_contract {
    demo page
} {
    {name "Charlie Brown"}
    {interest:html "lying on the roof with snoopy"}
    {interest_format text/html}
    {keywords ""}
}

set form_name user_info
ad_form -name $form_name -form {
    {name:text(inform) {label "Name :"} }
    {interest:text(richtext) {label "Narrative :"} }
    {keywords:text(text) {label "Keywords :"} }
} -mode display -after_submit {
    ns_log notice "final value of interest <$interest> format $interest_format"
    ad_returnredirect /
    ad_script_abort
} -on_request  {
    set interest [list $interest $interest_format]
} -on_validation_error {
    template::element::set_value $form_name interest [list $interest $interest_format]
} 

set title "Demo Page"
set context [list $title]
Collapse
Posted by Priya Rao on
Thanks a lot Gustaf.

on_validation_error block code has solved the issue.

Priya