Body: <p>Help, built new extension, form displays, accepts input, but never updates the database</p>
  
  <p>The returns I get from all functions do not show errors.</p>
  
  <p>What the heck am I doing wrong????</p>
  
  <p>It's going to be flipping obvious when its pointed out, but I've been pulling my hair out with this.</p>
  
  <p>So this:</p>
  
  <p>W:\bluline\drupal\sites\all\modules\civicrm\ext\net.ssl-uk.sslext\CRM\Sslext\Form\System.php</p>
  
  <pre><code>&lt;?php
  use CRM_sslext_ExtensionUtil as E;
  
  /** Form controller class */
  class CRM_sslext_Form_System extends CRM_Core_Form {
  
  public function postProcess() 
  {
      $result = civicrm_api3('Sslsystem', 'create', [ 'id' =&gt; 1,  'sysKey' =&gt; "abc", 'sysValue' =&gt; '123']);
  }
  }
  </code></pre>
  
  <p>Calls this:</p>
  
  <p>W:\bluline\drupal\sites\all\modules\civicrm\ext\net.ssl-uk.sslext\api\v3\Sslsystem\Create.php</p>
  
  <pre><code>&lt;?php
  use CRM_sslext_ExtensionUtil as E;
  
  function civicrm_api3_sslsystem_create($params) {
      $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
      return $result;
  }
  </code></pre>
  
  <p>Which calls this:</p>
  
  <p>W:\bluline\drupal\sites\all\modules\civicrm\ext\net.ssl-uk.sslext\api\v3\Sslsystem\Create.php</p>
  
  <pre><code>&lt;?php
  use CRM_sslext_ExtensionUtil as E;
  
  class CRM_sslext_BAO_sslsystem extends CRM_sslext_DAO_sslsystem {
    public static function create($params) {
      $className = 'CRM_sslext_DAO_sslsystem';
      $entityName = 'Sslsystem';
      $hook = empty($params['id']) ? 'create' : 'edit';
  
      CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
      $instance = new $className();
      $instance-&gt;copyValues($params);
      $instance-&gt;save();
      CRM_Utils_Hook::post($hook, $entityName, $instance-&gt;id, $instance);
      return $instance;
    } 
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-28T16:32:56.473Z
Comments.Text: There's nothing wrong with this on first glance.  If you use the API Explorer (**Support menu » Developer » API Explorer v3**), and you make the same API call, does it work?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-28T20:46:52.313Z
Comments.Text: Nope.  Exactly the same, no errors, just no database update.
Comments.UserDisplayName: Simon Walden
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-29T08:41:44.060Z
Comments.Text: Answering my own question:   The issue was with the  'id' => 1.   
  
  As ID 1 did not exist in database it did not create.  Removing the 'id' parameter so it was empty correctly creates the record.   
  
  
  Said it would be blindingly obvious once I spotted it.
Comments.UserDisplayName: Simon Walden
Tags: <api><extension><developer>
Title: Create API not updating database in new extension - what have I missed?
ThreadText: # Create API not updating database in new extension - what have I missed?
  
  (Asked by: username_0 on 2019-11-28)
  
  Help, built new extension, form displays, accepts input, but never updates the database
  The returns I get from all functions do not show errors.
  What the heck am I doing wrong????
  It's going to be flipping obvious when its pointed out, but I've been pulling my hair out with this.
  So this:
  W:\bluline\drupal\sites\all\modules\civicrm\ext\net.ssl-uk.sslext\CRM\Sslext\Form\System.php
   1,  'sysKey' => "abc", 'sysValue' => '123']);
  }
  }
  
  Calls this:
  W:\bluline\drupal\sites\all\modules\civicrm\ext\net.ssl-uk.sslext\api\v3\Sslsystem\Create.php
  
  Which calls this:
  W:\bluline\drupal\sites\all\modules\civicrm\ext\net.ssl-uk.sslext\api\v3\Sslsystem\Create.php
  copyValues($params);
      $instance->save();
      CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
      return $instance;
    } 
  }
  
  **Tags:** api, extension, developer
  
  > **Comments:**
  > **username_1**: There's nothing wrong with this on first glance.  If you use the API Explorer (**Support menu » Developer » API Explorer v3**), and you make the same API call, does it work?  
  > **username_0**: Nope.  Exactly the same, no errors, just no database update.  
  > **username_0**: Answering my own question:   The issue was with the  'id' => 1.     As ID 1 did not exist in database it did not create.  Removing the 'id' parameter so it was empty correctly creates the record.      Said it would be blindingly obvious once I spotted it.  
  
  ---
  
  ## 0 answers
  
  