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) »
  • <input> element in Profile/Dynamic.tpl
Pages: [1]

Author Topic: <input> element in Profile/Dynamic.tpl  (Read 429 times)

teja-amil

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Joomla! 3.2
  • MySQL version: 4
  • PHP version: 5
<input> element in Profile/Dynamic.tpl
June 17, 2014, 09:41:49 am
Hi

I am working on styling Civi forms differently. Currently, I am working on Profile page which uses CRM/Profile/Dynamic.tpl I have been able to access and style all other elements except <input>. I am unable to find the code for input. Can someone point me to the location/include from which this element is accessed?

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: <input> element in Profile/Dynamic.tpl
June 17, 2014, 04:38:50 pm
The <input> elements are generated dynamically based on the profile configuration. The most salient functions are CRM_Profile_Form::buildQuickForm() and CRM_Core_BAO_UFGroup::buildProfile():

https://github.com/civicrm/civicrm-core/blob/master/CRM/Profile/Form.php#L753
https://github.com/civicrm/civicrm-core/blob/master/CRM/Profile/Form.php#L775
https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/BAO/UFGroup.php#L1752

(Note: The syntax highlighting on Github looks a bit buggy for UFGroup.php. It may be easier to read that file locally in an IDE/code-editor.)

The key thing to note is that CRM_Profile_Form has a loop which looks like this:

Code: [Select]
  public function buildQuickForm() {
    // ...
    foreach ($this->_fields as $name => $field) {
      // ...
      CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
      // ...
    }
    // ...
  }

The buildProfile() function then has a number of conditionals which check for different field-types/configurations that may have been chosen by the site-admin. A typical one is:

Code: [Select]
elseif (substr($fieldName, 0, 7) === 'country') {
      $form->add('select', $name, $title,
        array(
          '' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required
      );

The "$form->add(...)" statement is responsible for creating the form element (eg <input>, <select>, or <textarea>). You can find some more info about them at http://wiki.civicrm.org/confluence/display/CRMDOC/QuickForm+Reference .

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • <input> element in Profile/Dynamic.tpl

This forum was archived on 2017-11-26.