function mailchimp_campaign_get_entity_import_form_elements in Mailchimp 7.5
Same name and namespace in other branches
- 7.3 modules/mailchimp_campaign/includes/mailchimp_campaign.admin.inc \mailchimp_campaign_get_entity_import_form_elements()
- 7.4 modules/mailchimp_campaign/includes/mailchimp_campaign.admin.inc \mailchimp_campaign_get_entity_import_form_elements()
Gets form elements used in the entity import feature.
Parameters
string $entity_type: The type of entity to import.
string $section: The content section these fields are displayed in.
Return value
array Array of form elements used to display entity imports.
1 call to mailchimp_campaign_get_entity_import_form_elements()
- mailchimp_campaign_campaign_form in modules/
mailchimp_campaign/ includes/ mailchimp_campaign.admin.inc - Returns a form for creating a campaign.
File
- modules/
mailchimp_campaign/ includes/ mailchimp_campaign.admin.inc, line 316 - Administration pages for mailchimp_campaign module.
Code
function mailchimp_campaign_get_entity_import_form_elements($entity_type, $section) {
$form = array();
// Get available entity types.
$entity_info = _mailchimp_campaign_get_entities_for_content_import();
$entity_options = _mailchimp_campaign_build_entity_option_list($entity_info);
$form['entity_import'] = array(
'#id' => 'entity-import',
'#type' => 'fieldset',
'#title' => t('Insert site content'),
'#description' => t('<b>For use only with text filters that use the MailChimp Campaign filter</b><br />You can insert an entity of a given type and pick the view mode that will be rendered within this campaign section.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['entity_import']['entity_type'] = array(
'#type' => 'select',
'#title' => t('Entity Type'),
'#options' => $entity_options,
'#default_value' => $entity_type,
'#ajax' => array(
'callback' => 'mailchimp_campaign_entity_type_callback',
'wrapper' => $section . '-content-entity-lookup-wrapper',
),
);
$form['entity_import']['entity_type']['#attributes']['class'][] = $section . '-entity-import-entity-type';
$form['entity_import']['entity_import_wrapper'] = array(
'#type' => 'container',
'#attributes' => array(
'id' => $section . '-content-entity-lookup-wrapper',
),
);
if ($entity_type != NULL) {
// Get available entity view modes.
$entity_view_mode_options = _mailchimp_campaign_build_entity_view_mode_option_list($entity_info[$entity_type]);
$form['entity_import']['entity_id'] = array(
'#type' => 'textfield',
'#title' => t('Entity Title'),
// Pass entity type as first parameter to autocomplete callback.
'#autocomplete_path' => 'admin/config/services/mailchimp/campaigns/entities/' . $entity_type,
);
$form['entity_import']['entity_id']['#id'] = $section . '-entity-import-entity-id';
$form['entity_import']['entity_view_mode'] = array(
'#type' => 'select',
'#title' => t('View Mode'),
'#options' => $entity_view_mode_options,
'#attributes' => array(
'id' => $section . '-entity-import-entity-view-mode',
),
);
}
$form['entity_import']['entity_import_link'] = array(
'#type' => 'item',
'#markup' => '<a id="' . $section . '-add-entity-token-link" class="add-entity-token-link" href="javascript:void(0);">' . t('Insert entity token') . '</a>',
'#states' => array(
'invisible' => array(
':input[name="content[' . $section . '_wrapper][entity_import][entity_type]"]' => array(
'value' => '',
),
),
),
);
$form['entity_import']['entity_import_tag'] = array(
'#type' => 'container',
'#attributes' => array(
'id' => $section . '-entity-import-tag-field',
),
'#states' => array(
'invisible' => array(
':input[name="content[' . $section . '_wrapper][entity_import][entity_type]"]' => array(
'value' => '',
),
),
),
);
return $form;
}