Hi,
I am trying to use Lars new user widget in ad_form and I'm having some trouble getting it to work properly.
I'd like to use this cool widget to assign an owner to some object. In addition to the "owner_id" element my add/edit form has a "name" element that isn't optional... Now, when I request the form (without a key_id), enter a name, select "Search for other user..." in the pulldown and submit I get a request error because ad_form's "-new_data" block tries to insert ":other:" into my db. That is the value I submitted, of course, but somehow ad_form (or the user widget) neglects to render the user search field...
However, when I leave the name field empty in the add-form and select "Search for other user..." and hit submit a new form is rendered because name was required. This time the user search text box shows up and I can search for users as intended and fulfill the task.
I may have done something wrong when I defined my ad_form call but I can't discover it myself. Has anyone got any word of advise?
Here's my test code:
ad_form -form {
table_id:key
{name:text(text) {label "Name"}
{html {size 50}}}
{owner_id:text(user) {label "Owner"}
{options $users_list} optional}
} -select_query {
select name,
owner_id
from table
where table_id = :table_id
} -validate {
{name
{[string length $name] <= 200}
"Name may not be more than 200 characters long"
}
} -new_data {
my_object::new -name $name
-owner_id $owner_id
-package_id [ad_conn package_id]
ad_returnredirect "."
return
} -edit_data {
my_object::edit -table_id $table_id
-name $name
ad_returnredirect "."
return
}
ad_return_template