Issue Details (XML | Word | Printable)

Key: CRM-5246
Type: Improvement Improvement
Status: Reopened Reopened
Priority: Trivial Trivial
Assignee: Donald A. Lobo
Reporter: Tom Kirkpatrick
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
CiviCRM

Patch HTML_Quickform to add optgroup support for select dropdowns

Created: 17/Oct/09 08:33 AM   Updated: 14/Dec/11 07:03 PM
Component/s: None
Affects Version/s: 3.0.1
Fix Version/s: 4.3

Time Tracking:
Not Specified

File Attachments: 1. Text File civicrm-3.0.0-quickform-add-optgroup-support.patch (7 kB)
2. Text File civicrm-3.3.6-quickform-add-optgroup-support.patch (9 kB)
3. Text File civicrm-3.3.6-quickform-add-optgroup-support.patch (8 kB)
4. Text File civicrm-3.3.6-quickform-add-optgroup-support.patch (8 kB)



 Description  « Hide
Whilst trying to tidy up the Country select dropdown, as described at http://issues.civicrm.org/jira/browse/CRM-5227 I found myself needing to group the countries using <optgroup> within the select. Though this is possible with HTML_Quickform2, CiviCRM is currently using HTML_Quickform1, and this feature is unavailable. Whilst looking for a solution, I found http://pear.php.net/bugs/bug.php?id=1283&thanks=3 where HTML_Quickform1 has been hacked to add in the support. I rolled up the said changes into a patch (http://pear.php.net/bugs/bug.php?id=1283&edit=12&patch=add-optgroup-support&revision=1255771468) and applied it to CiviCRM (attached). It seems to work absolutely fine :)

For reference, this is how I'm using it, in hook_civicrm_buildForm:

      // rebuild the country selecter to only contain the UK and select UK by default
      foreach(CRM_Core_PseudoConstant::country() as $key => $value) {
        if ($key == '1105' || $key == '1226') {
          $topCountries[$key] = $value;
        }
        else {
          $otherCountries[$key] = $value;
        }
      }
      $finalCountries = array('' => '- select -') + $topCountries + array(' ---------- ' => $otherCountries);
      $form->addElement('select', 'billing_country_id-'. $form->_bltID, ts('Country'), $finalCountries);

 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Donald A. Lobo added a comment - 19/Oct/09 03:49 PM

hey tom:

any chance u can recreate this patch for 3.1.

We've upgraded all the PEAR packages to the latest version

thanx

lbo

Tom Kirkpatrick added a comment - 23/Oct/09 09:46 AM
Patch apples cleanly to 3.0.1, and works fine.

Donald A. Lobo added a comment - 26/Oct/09 05:57 PM

had to redo the patch for 3.1 due to changes in QF/Civi

Donald A. Lobo added a comment - 30/Oct/09 12:50 AM

This fix broke advmultiselect (verified) and also frozen select values

dont have time to investigate, hece reopening. TomK can u verify (a good page to check is enable components)

Tom Kirkpatrick added a comment - 30/Oct/09 10:01 AM
I can confirm this issue. There do appear to be selectable options in the advanced multiselect, but the text for each one is blank, rendering the control unusable.

Tom Kirkpatrick added a comment - 30/Mar/11 06:44 PM
Here is an updated patch against CiviCRM 3.3.6 which solve the issue with multiselect and frozen selects.

Tom Kirkpatrick added a comment - 05/Apr/11 03:25 PM
Revised patch fixes a problem with frozen elements. This should be all good now :)

Tom Kirkpatrick added a comment - 21/Sep/11 09:19 AM
Bloody hell. Last patch was missing a function! Here it is again.