Answers.Body: <p>Afform is still in beta so I expect this functionality to improve further, but currently it does support passing in an id via the url. It keys off the <code>af-entity</code> name property. So if you visit your form and add <code>?member=123</code> to the end of the url string it should load contact id 123 as the &quot;Member&quot;. In that case it will update instead of creating a new contact.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-22T01:20:48.527Z
Answers.Text: Thanks for the follow up. I was hoping to set a value that does not come from the database - in other words, I want the form to submit a new contact, but I want the first and last names to be pre-populated on the form. Maybe not possible yet.
Answers.UserDisplayName: Jamie
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-22T01:03:03.593Z
Answers.LastActivityDate: 2020-12-22T01:03:03.593Z
Answers.UserDisplayName: Coleman
Body: <p>I'm working on my first afform extension.</p>
  <p>I've built a form, which works! I can submit values and create a contact.</p>
  <p>However, I can't figure out how to pre-populate with default values. This is pretty important for the application. I've tried a number of things but none of them seem to work (not even the 'defn` one which came from a published example). Any suggestions? Note: I don't want to populate the form with the values from an existing contact. I need to insert new values into the form so when submitted, it creates a new contact.</p>
  <pre><code> &lt;af-form ctrl=&quot;modelListCtrl&quot;&gt;
          &lt;af-entity type=&quot;Contact&quot; name=&quot;member&quot; label=&quot;Member&quot; /&gt;
          &lt;div af-fieldset=&quot;member&quot;&gt;
            &lt;af-field name=&quot;first_name&quot; ng-init=&quot;first_name = 'Betty'&quot; /&gt;
            &lt;af-field name=&quot;last_name&quot; value=&quot;Smith&quot; /&gt;
            &lt;af-field name=&quot;do_not_email&quot; defn=&quot;{type: 'checkbox', default: 1}&quot; /&gt;
          &lt;/div&gt;                                             
          &lt;button ng-click=&quot;modelListCtrl.submit()&quot;&gt;Submit&lt;/button&gt;                                                                                              
    &lt;/af-form&gt; 
  </code></pre>
  
Tags: <angular><formbuilder>
Title: How do I set default values in afform?
ThreadText: # How do I set default values in afform?
  
  (Asked by: username_0 on 2020-12-21)
  
  I'm working on my first afform extension.
  I've built a form, which works! I can submit values and create a contact.
  However, I can't figure out how to pre-populate with default values. This is pretty important for the application. I've tried a number of things but none of them seem to work (not even the 'defn` one which came from a published example). Any suggestions? Note: I don't want to populate the form with the values from an existing contact. I need to insert new values into the form so when submitted, it creates a new contact.
   
          
          
            
            
            
                                                       
          Submit
  
  **Tags:** angular, formbuilder
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-12-22. Score: 2
  
  Afform is still in beta so I expect this functionality to improve further, but currently it does support passing in an id via the url. It keys off the `af-entity` name property. So if you visit your form and add `?member=123` to the end of the url string it should load contact id 123 as the "Member". In that case it will update instead of creating a new contact.
  
  > **Comments:**
  > **username_0**: Thanks for the follow up. I was hoping to set a value that does not come from the database - in other words, I want the form to submit a new contact, but I want the first and last names to be pre-populated on the form. Maybe not possible yet.  
  
  ---
  
  