Results 1 to 2 of 2

Thread: pass data to popup

  1. #1
    zaska's Avatar
    zaska is offline Senior Member
    Join Date
    Sep 2008
    Posts
    99

    Default pass data to popup

    Hi,

    In subpanel 'Contacts' in ProspectLists I want to select some contacts with checkbox, click "Select List", and select a ProspectList from the popup to relate these contacts. I'm associating the contact ids to the checkboxes but don't know how to pass these ids to the popuped window.

    modules/ProspectLists/metadata/subpanels/ForContacts.php:
    PHP Code:
    $subpanel_layout = array(
            
    'top_buttons' => array(
                    array(
    'widget_class' => 'SubPanelTopCreateButton'),
                    array(
    'widget_class' => 'SubPanelTopSelectButton''popup_module' => 'Contacts'),
                    array(
    'widget_class' => 'SubPanelTopAddToListButton'),
            ),

            
    'where' => '',



            
    'list_fields' => array(
                    
    'checkboxes'=>array(
                            
    'vname' => 'LBL_CHECKBOX',
                            
    'widget_class' => 'SubPanelCheckBox',
                            
    'sortable' => false,
                    ),
    // rest of the panel 
    include/generic/SugarWidgets/SugarWidgetSubPanelCheckBox.php:
    PHP Code:
    <?php
    require_once('include/generic/SugarWidgets/SugarWidgetField.php');

    class 
    SugarWidgetSubPanelCheckBox extends SugarWidgetField
    {
            function 
    displayList(&$layout_def)
            {

                    
    $contact_id NULL;
                    if (
    $layout_def['fields'] && is_array($layout_def['fields'])) {
                            
    $contact_id $layout_def['fields']['ID'];
                    }

                    
    $checkbox "<INPUT type=\"checkbox\" name=\"contact_checkbox[]\" value=\"$contact_id\">";

                    return 
    $checkbox;
            }
    }
    ?>
    SugarWidgetSubPanelTopAddToListButton.php is a copy of SugarWidgetSubPanelTopSelectContactsButton.php with different button value and popup module.

    SugarCE 5.2.0e
    Thanks

  2. #2
    zaska's Avatar
    zaska is offline Senior Member
    Join Date
    Sep 2008
    Posts
    99

    Thumbs up Re: pass data to popup

    I've added a custom callback function:

    Code:
    function set_return_and_save_background_custom(popup_reply_data) {
            var name_to_value_array = popup_reply_data.name_to_value_array;
            var post_string = "custom/modules/ProspectLists/AddContactsToList.php?";
            var the_key = "prospect_list_id";
            var the_value = name_to_value_array[the_key];
            post_string = post_string + the_key + "=" + the_value + "&";
            var contact_checked = document.getElementsByName('contact_checkbox');
            var contact_ids_post = new Array();
            for (i=0;i<contact_checked.length;i++) {
                    if (contact_checked[i].checked) {
                            contact_ids_post.push('contact_ids[]='+contact_checked[i].value);
                    }
            }
            contact_ids_post = contact_ids_post.join('&');
            post_string = post_string + contact_ids_post;
            parent.location=post_string;
    }
    Then in custom/modules/ProspectLists/AddContactsToList.php checking and making the relationship. I know.. it's ugly.. but it's working.

    Can anyone tell me how to use that js function upgrade safe? Now it's in include/SubPanel/SubPanelTiles.js

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. filter popup data by relation
    By waverider in forum Developer Help
    Replies: 6
    Last Post: 2008-09-18, 02:23 PM
  2. popup data display
    By sparklearun in forum Help
    Replies: 0
    Last Post: 2008-03-17, 06:00 AM
  3. How to pass form data to new lead screen
    By amymicheals in forum Developer Help
    Replies: 0
    Last Post: 2007-12-28, 06:25 AM
  4. How is data transferred from a popup to the parent
    By lvangool in forum Developer Help
    Replies: 2
    Last Post: 2006-09-07, 01:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •