1999 Posts in 1408 Topics by 613 members
|Go to End|
7 February 2009 at 2:13am
I am trying to set the default value of a dropdown which is generated from the ->toDropdownMap function, but it doesnt seem to work. Here is my code:
new DropdownField('Service', 'Service', Dataobject::get("ServicePage")->toDropdownMap("ID", "Title"), $value=15)
The default just remains as the first Item in the list. I noticed the isSelected() function in the api docs, but I'm not sure where to call that if it's what I need?
Any help is much appreciated
7 February 2009 at 6:52am
OK, I'm being a muppet, this does work, but doesn't change when you hit refresh, gotta load the page by revisiting the URL....
7 February 2009 at 7:18am
Where is the value of $value coming from?
7 February 2009 at 7:34am Last edited: 7 February 2009 7:36am
it being passed into the page via the URL, it's the ID of the page the user clicked through to get to the form.
It's for a quote page, each service provided by the client has a page with a get quote button, so if you click it then it takes you to the quote form which has the service type drop down pre-populated.
|Go to Top|