CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Adding new form fields to template/php and saving to DB not working
Pages: [1]

Author Topic: Adding new form fields to template/php and saving to DB not working  (Read 926 times)

seb

  • I’m new here
  • *
  • Posts: 26
  • Karma: 1
  • CiviCRM version: 4.6.4
  • CMS version: Drupal 7/Drupal 8
  • MySQL version: Ver 14.14 Distrib 5.5.44, for debian-linux-gnu
  • PHP version: PHP 5.6.9-0+deb8u1
Adding new form fields to template/php and saving to DB not working
February 10, 2014, 03:00:23 pm
While trying to implement partial payments, I modified the ManageEvent/fee.tpl and .php to add partial_payment_receipt and partial_payment_text (and min_initial_amount), as well as created the column in the event database. 

These were done exactly the same way that the pay_later_receipt and pay_later_text is done, but for some reason no information is loaded or saved from these new fields, and I am having some trouble figuring out why this is the case.  The min_initial_amount field itself is updating to the DB fine.

I've added the partial_payment_text/receipt in all files that pay_later is using that relates to events..  (based off a global grep for pay_later from the civicrm root dir). This includes the event DAO object itself.

The main code from fee.php looks like such, showing my addition and the original pay_later fields..

Code: [Select]
    //SEBEDIT - add partial-payment options
    $this->addElement('checkbox', 'is_partial_payment', ts('Enable Partial Payments?'), NULL,
      array('onclick' => "return showHideByValue('is_partial_payment','','is_partial_paymentOptions','block','radio',false);")
    );
    $this->addElement('textarea', 'partial_payment_text', ts('Partial Payment Label'),
      CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'partial_payment_text'),
      FALSE
    );
    $this->add('text', 'min_initial_amount', ts('Minimum Payment'));

    $this->addWysiwyg('partial_payment_receipt', ts('Partial Payment Instructions'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'partial_payment_receipt'));
 
   
    // add pay later options
    $this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL,
      array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);")
    );
    $this->addElement('textarea', 'pay_later_text', ts('Pay Later Label'),
      CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_text'),
      FALSE
    );
    $this->addWysiwyg('pay_later_receipt', ts('Pay Later Instructions'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_receipt'));

The template fee.tpl is as such:
Code: [Select]
        <table id="is_partial_payment" class="form-layout">
            <tr class="crm-event-manage-fee-form-block-is_partial_payment">
               <td class="extra-long-fourty label">{$form.is_partial_payment.html}</td>
               <td>{$form.is_partial_payment.label}<br />
                  <span class="description">{ts}Check this box if you want to give users the option to submit a partial payment (e.g. a security deposit to reserve a spot in an event.).{/ts}</span>
              </td>
            </tr>
        </table>

        <table id="is_partial_paymentOptions" class="form-layout">
            <tr class="crm-event-manage-fee-form-block-partial_payment_text">
               <td class="label">{$form.partial_payment_text.label}<span class="marker"> *</span> </td>
               <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='partial_payment_text' id=$id}{/if}{$form.partial_payment_text.html|crmAddClass:big}
               </td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td class="description">{ts}Text displayed next to the checkbox for the 'Partial Payments' option on the contribution form. You may include HTML formatting tags.{/ts}</td>
            </tr>

            <tr class="crm-event-manage-fee-form-block-min_initial_amount">
               <td class="label">{$form.min_initial_amount.label}<span class="marker"> *</span>
               </td>
               <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='min_initial_amount' id=$id}{/if}{$form.min_initial_amount.html}
               </td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td class="description">{ts}Enter the minimum amount accepted as a partial payment.{/ts}
               </td>
            </tr>
           
            <tr class="crm-event-manage-fee-form-block-partial_payment_receipt">
               <td class="label">{$form.partial_payment_receipt.label}<span class="marker"> *</span> </td>
               <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='partial_payment_receipt' id=$id}{/if}{$form.partial_payment_receipt.html|crmAddClass:big}
               </td>
            </tr>           
            <tr>
                <td>&nbsp;</td>
                <td class="description">{ts}Instructions added to Confirmation and Thank-you pages when the user selects the 'partial payment' option (e.g. 'Submit the sum of your payment to ... within 3 business days.').{/ts}
                </td>
            </tr>
        </table>
       
        <table id="payLater" class="form-layout">
            <tr class="crm-event-manage-fee-form-block-is_pay_later">
               <td class="extra-long-fourty label">{$form.is_pay_later.html}</td>
               <td>{$form.is_pay_later.label}<br />
                  <span class="description">{ts}Check this box if you want to give users the option to submit payment offline (e.g. mail in a check, call in a credit card, etc.).{/ts}</span>
              </td>
            </tr>
        </table>

        <table id="payLaterOptions" class="form-layout">
            <tr class="crm-event-manage-fee-form-block-pay_later_text">
               <td class="label">{$form.pay_later_text.label}<span class="marker"> *</span> </td>
               <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='pay_later_text' id=$id}{/if}{$form.pay_later_text.html|crmAddClass:big}
               </td>
            </tr>
            <tr>
               <td>&nbsp;</td>
               <td class="description">{ts}Text displayed next to the checkbox for the 'pay later' option on the contribution form. You may include HTML formatting tags.{/ts}</td>
            </tr>
            <tr class="crm-event-manage-fee-form-block-pay_later_receipt">
               <td class="label">{$form.pay_later_receipt.label}<span class="marker"> *</span> </td>
               <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='pay_later_receipt' id=$id}{/if}{$form.pay_later_receipt.html|crmAddClass:big}
               </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td class="description">{ts}Instructions added to Confirmation and Thank-you pages when the user selects the 'pay later' option (e.g. 'Mail your check to ... within 3 business days.').{/ts}
                </td>
            </tr>
        </table>

(These are placed in my custom template and php dirs)

I am having some trouble figuring out why the exact same code works for pay_later_text and _receipt, but not for my new entries. Hmm!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Adding new form fields to template/php and saving to DB not working

This forum was archived on 2017-11-26.