Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pre-select a value from a dropdown list with meteor and autoform?

I'm using autoform with simple-schema and trying to pre-select a value from a dropdown list. I either crash the app or get no notice, no result, nothing. The selected value still shows (Select One). Here's the block from my schema:

status:{
  type: String,
  label: "Status",
  allowedValues: ['Approved','Pending','Flagged'],
  autoValue: function() {
    return {label: 'Pending', value: 'Pending'};
  }
},
like image 488
RyGuy Avatar asked Feb 11 '23 12:02

RyGuy


2 Answers

Add the value attribute.

{{afQuickField name="fieldName" options="allowed" value="option1"}}

Found here: https://github.com/aldeed/meteor-autoform/issues/52

like image 91
Mokolodi1 Avatar answered Apr 30 '23 03:04

Mokolodi1


Taken from the documentation: https://github.com/aldeed/meteor-autoform#affieldinput

To specify a label to be displayed when there is no option selected, set firstOption="(My Select One Label)".

firstOption: Use with the options attribute to specify a string to use for the first option of a select input, which shows when nothing has been selected yet. For example, firstOption="(You Should Really Pick Something From This List)". There is a default first option "(Select One)". If you don't want any default option, then do firstOption=false, but make sure your select input has a default value or this will result in a confusing UX where it looks like the first option is selected but it isn't.

like image 21
Liko Avatar answered Apr 30 '23 04:04

Liko