1779 Posts in 582 Topics by 556 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 3286 Views |
-
Set default value on dynamic DropdownField

7 February 2009 at 2:13am
Hi Guys
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
-
Re: Set default value on dynamic DropdownField

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....
-
Re: Set default value on dynamic DropdownField

7 February 2009 at 7:18am
Aram,
Where is the value of $value coming from?
-
Re: Set default value on dynamic DropdownField

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.
| 3286 Views | ||
|
Page:
1
|
Go to Top |

