Hi, I can't quite figure out how to do this. I would like to set the "format" value for a richtext widget while using ad_form. Here's my code:
ad_form -name department_form -action department-ae -form {
{department_id:key}
{abbrev:text {label "Abbreviated Code"} {html {size 4 maxlength 20}}}
{label:text {label "Label"} {html {size 40 maxlength 255}}}
{description:richtext(richtext) {label "Description"} {html {rows 10 cols 40}}}
} -new_request {
} -edit_request {
db_1row get_instructor_info { select abbrev, label, description, description_format from course_departments where department_id = :department_id }
template::util::richtext::set_property contents description $description
template::util::richtext::set_property format description $description_format
} -validate {
} -on_submit {
set description_format [template::util::richtext::get_property format $description]
set description [template::util::richtext::get_property contents $description]
} -new_data {
set department_id [department::create -department_id $department_id -abbrev $abbrev -label $label -description $description -description_format $description_format]
} -edit_data {
department::edit -department_id $department_id -abbrev $abbrev -label $label -description $description -description_format $description_format
} -after_submit {
ad_returnredirect "departments"
ad_script_abort
}
It extracts the format when it is submitted and stuffs that value into the database, but when i return to this page to edit the content it reverts back to "enhanded text".
The line template::util::richtext::set_property contents description $description
doesn't actually do anything, but form api-doc it seemed like this was needed. i think the pull from the database with a field named "description" is what sets that value. Thanks for the help!