Merge pull request #18631 from eileenmcnaughton/ppp
[civicrm-core.git] / CRM / Contact / Form / Edit / IM.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Form helper class for an IM object.
20 */
21 class CRM_Contact_Form_Edit_IM {
22
23 /**
24 * Build the form object elements for an IM object.
25 *
26 * @param CRM_Core_Form $form
27 * Reference to the form object.
28 * @param int $blockCount
29 * Block number to build.
30 * @param bool $blockEdit
31 * Is it block edit.
32 */
33 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
34 if (!$blockCount) {
35 $blockId = ($form->get('IM_Block_Count')) ? $form->get('IM_Block_Count') : 1;
36 }
37 else {
38 $blockId = $blockCount;
39 }
40 $form->applyFilter('__ALL__', 'trim');
41
42 //IM provider select
43 $form->addField("im[$blockId][provider_id]", ['entity' => 'im', 'class' => 'eight', 'placeholder' => NULL]);
44 //Block type select
45 $form->addField("im[$blockId][location_type_id]", ['entity' => 'im', 'class' => 'eight', 'placeholder' => NULL, 'option_url' => NULL]);
46
47 //IM box
48 $form->addField("im[$blockId][name]", ['entity' => 'im', 'aria-label' => ts('Instant Messenger %1', [1 => $blockId])]);
49 //is_Primary radio
50 $js = ['id' => 'IM_' . $blockId . '_IsPrimary', 'aria-label' => ts('Instant Messenger %1 is primary?', [1 => $blockId])];
51 if (!$blockEdit) {
52 $js['onClick'] = 'singleSelect( this.id );';
53 }
54
55 $form->addElement('radio', "im[$blockId][is_primary]", '', '', '1', $js);
56 }
57
58 }