Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/Core#785: Extend addField to support select2 widget #14416

Merged
merged 1 commit into from
Jun 3, 2019

Conversation

monishdeb
Copy link
Member

Overview

Currently, CiviCRM support select widget via Form::addField() but that doesn't allow us to use the features of select2 like rendering icon against each option. This PR extends addField() to support select2 widget along with select

Before

Suppose you want to add an icon only against smart group option(s) it was not possible earlier to simply use

$groupHierarchy = [
1 => [
   .. metdata..
  'name' => 'Smart Group'
   icon => 'fa-bulb-o'
  ],
..
];

$this->addField('group', array[
          'entity' => 'group_contact',
          'label' => ts('in'),
          'placeholder' => ts('- any group -'),
          'options' => $groupHierarchy,
          'type' => 'Select',
        ]);

won't work.
Screen Shot 2019-04-04 at 5 54 08 PM

After

But this will:

$this->addField('group', array[
          'entity' => 'group_contact',
          'label' => ts('in'),
          'placeholder' => ts('- any group -'),
          'options' => $groupHierarchy,
          'type' => 'Select2',
        ]);

Screen Shot 2019-04-04 at 5 42 38 PM

@civibot
Copy link

civibot bot commented Jun 3, 2019

(Standard links)

@monishdeb
Copy link
Member Author

Thanks @mattwire :)

@seamuslee001 seamuslee001 merged commit 78c612d into civicrm:master Jun 3, 2019
@monishdeb
Copy link
Member Author

Thanks @seamuslee001 for merging it :)

@monishdeb monishdeb deleted the core-785-1 branch June 3, 2019 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants