Answers.Body: <p>I did this by using CiviCRM hooks (BuildForm).</p>
  
  <pre><code>($form == CRM_Core_Action::ADD) {
          $currentDate = date('d/m/Y');
          for ($i = 1; $i &lt; 10000; $i++) {
              $defaults['custom_197_-' . $i] = $currentDate;
              $form-&gt;updateElementAttr('custom_197_-'. $i,array('readonly'));
          }
          $form-&gt;setDefaults($defaults);
         } 
  </code></pre>
  
  <p>This is working</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-28T11:03:04.130Z
Answers.LastActivityDate: 2019-10-28T11:03:04.130Z
Answers.UserDisplayName: Moe
Body: <p>I have a created a custom group and a custom field within that group.</p>
  
  <p>One of the Custom fields is Date.</p>
  
  <p>Is there any way to autoload 'current date' (today) in the default value field Using a hook or something?</p>
  
  <p>I have been googling but i am not getting any results.</p>
  
  <p>Thanks</p>
  
Tags: <custom-fields><civireport>
Title: Default Value for Custom Field
ThreadText: # Default Value for Custom Field
  
  (Asked by: username_0 on 2019-10-18)
  
  I have a created a custom group and a custom field within that group.
  
  One of the Custom fields is Date.
  
  Is there any way to autoload 'current date' (today) in the default value field Using a hook or something?
  
  I have been googling but i am not getting any results.
  
  Thanks
  
  **Tags:** custom-fields, civireport
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-10-28. Score: 0 | Accepted answer
  
  I did this by using CiviCRM hooks (BuildForm).
  
  ```
  ($form == CRM_Core_Action::ADD) {
          $currentDate = date('d/m/Y');
          for ($i = 1; $i < 10000; $i++) {
              $defaults['custom_197_-' . $i] = $currentDate;
              $form->updateElementAttr('custom_197_-'. $i,array('readonly'));
          }
          $form->setDefaults($defaults);
         } 
  
  ```
  
  This is working
  
  
  ---
  
  