Answers.Body: <p>Themak, Nice question. This are hardcoded in core file but you can create your own field  for each payment method using buildform hook. Here is the snippet on how to do that</p>
  
  <pre><code>function custom_civicrm_buildForm($formName, &amp;$form) {
    if ($formName == 'CRM_Financial_Form_Payment' &amp;&amp; !empty($form-&gt;paymentInstrumentID)) {
      if ($form-&gt;paymentInstrumentID == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Test')) {
        $form-&gt;assign('paymentFields', array('source'));
        $form-&gt;add('text', 'source', ts('Source'));
      }
    }
  }
  </code></pre>
  
  <blockquote>
    <p><strong>Note:</strong> The above snippet is not fully tested i have just created blindly, but i am 100% sure it should work</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-11T20:30:31.807Z
Answers.LastActivityDate: 2018-10-11T20:30:31.807Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>So I understand that you can assign a payment processor any payment method - however - I am trying to create payment methods that replicate the behavior of Credit Card and Check.  For example - when manually adding Check or Credit Card contributions - you will then get a field for check number or last 4 digits of the card respectively.  </p>
  
  <p>If I make a payment method called <em>credit card - other</em>, I would want those credit card fields to also populate.</p>
  
  <p>Is this hard coded?</p>
  
Tags: <civicontribute><payment>
Title: Creating a custom payment method with conditional field
ThreadText: # Creating a custom payment method with conditional field
  
  (Asked by: username_0 on 2018-10-11)
  
  So I understand that you can assign a payment processor any payment method - however - I am trying to create payment methods that replicate the behavior of Credit Card and Check. For example - when manually adding Check or Credit Card contributions - you will then get a field for check number or last 4 digits of the card respectively.
  
  If I make a payment method called *credit card - other*, I would want those credit card fields to also populate.
  
  Is this hard coded?
  
  **Tags:** civicontribute, payment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-11. Score: 3 | Accepted answer
  
  username_0, Nice question. This are hardcoded in core file but you can create your own field for each payment method using buildform hook. Here is the snippet on how to do that
  
  ```
  function custom_civicrm_buildForm($formName, &$form) {
    if ($formName == 'CRM_Financial_Form_Payment' && !empty($form->paymentInstrumentID)) {
      if ($form->paymentInstrumentID == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Test')) {
        $form->assign('paymentFields', array('source'));
        $form->add('text', 'source', ts('Source'));
      }
    }
  }
  
  ```
  
  > **Note:** The above snippet is not fully tested i have just created blindly, but i am 100% sure it should work
  
  
  ---
  
  