Forum OpenACS Development: Problem with ad_form

Collapse
Posted by Matthew Coupe on
Hello,

I'm trying to give the option for users of my dotLRN the option of logging straight into a different community depending on what type of user they are. To do this I'm modifying the login form in acs-subsite but I'm having problems with my ad_form.

I need to be able to present a form with a select value which corresponds to the community id or something along those lines but I cannot get my add form to have a value and a label.

This is some code I'm playing around with to try and display a value in the select part of the form but it keeps giving an empty string.

ad_form -name test -form {

{title:text(text) {label "title"} }
{login_select:text(select) {label "category"} { options {"student" } { value "student" }}}

}

If anyone knows where I'm going wrong please help!!

Matthew

Collapse
2: Re: Problem with ad_form (response to 1)
Posted by Dave Bauer on
You options element should be a list of lists like this:

{options { {label value} {lable value} } }

Where each value label pair is a list and all those lists are in another list.

Collapse
Posted by Matthew Coupe on
Thanks for the help Dave but I still can't seem to get it! I think I know what you mean and I've put my code below.

I've been playing around with all kinds of permetations of this today! I'm close, I can sense it...

I went with something along these lines...

set title "words"
set login_labels [list student teacher]
set login_values [list student teacher]
set login_listoflists [list $login_labels $login_values]

ad_form -name test -form {
{title:text(text) {label "Title"} }
{login_id:text(select)
{label "category"}
{options {$login_listoflists}}
}

Anyone see where I'm going wrong this time?
I need the HTML output to look something like this...

select name="login_id"
option value="student"student /option
option value="centre"centre /option
/select

At the moment it keeps giving me either an error or something like this...

Anyone see where I'm going wrong this time?
I need the HTML output to look something like this...

select name="login_id"
option value=""student/option
option value=""centre/option
/select

Thanks in advance!
Matthew

Collapse
Posted by Matthew Coupe on
Why do you always figure it out just after you've asked for help!

I followed your template up there but replaced the label and value with the values I wanted (not putting them in a list object) and it worked. I'll play around with the list object now too but as long as I've got it working I should be ok.

Thanks! Matthew