function _linkit_build_profile_type_form_fields in Linkit 7.3
Append profile type form element to the profile form.
Parameters
LinkitProfile $profile: A profile object contains all settings for the profile.
See also
1 call to _linkit_build_profile_type_form_fields()
- linkit_profiles_form in plugins/
export_ui/ linkit_profiles.inc - Linkit profile settings form.
File
- plugins/
export_ui/ linkit_profiles.inc, line 124
Code
function _linkit_build_profile_type_form_fields(&$form, LinkitProfile $profile) {
$form['data']['profile_type'] = array(
'#type' => 'fieldset',
'#title' => t('Profile type'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => FALSE,
);
$form['data']['profile_type']['profile_type'] = array(
'#title' => t("This profile will be used with"),
'#type' => 'radios',
'#title_display' => 'before',
'#options' => array(
LINKIT_PROFILE_TYPE_EDITOR => t('Editors'),
LINKIT_PROFILE_TYPE_FIELD => t('Fields'),
LINKIT_PROFILE_TYPE_MENU => t('Menus'),
),
LINKIT_PROFILE_TYPE_EDITOR => array(
'#description' => t('This profile will be used with editors like CKeditor or TinyMCE.'),
),
LINKIT_PROFILE_TYPE_FIELD => array(
'#description' => t('This profile will be used with fields that do not have any editors.'),
),
LINKIT_PROFILE_TYPE_MENU => array(
'#description' => t('This profile will be used with menu links.'),
),
'#default_value' => isset($profile->profile_type) ? $profile->profile_type : 'editor',
'#required' => TRUE,
'#parents' => array(
'profile_type',
),
);
$formats = array();
foreach (filter_formats() as $format) {
$formats[$format->format] = $format->name;
}
$form['data']['profile_type']['text_formats'] = array(
'#type' => 'checkboxes',
'#title' => t('Attach this profile to one or more text formats'),
'#options' => $formats,
'#empty_option' => t('- Select one or more text format- '),
'#default_value' => isset($profile->data['text_formats']) ? $profile->data['text_formats'] : array(),
'#states' => array(
'visible' => array(
// While waiting for https://drupal.org/node/879580 to be commited, we
// have to convert the constant to a string.
'input[name="profile_type"]' => array(
'value' => (string) LINKIT_PROFILE_TYPE_EDITOR,
),
),
),
'#parents' => array(
'data',
'text_formats',
),
);
// Button text (for Menu type only).
$form['data']['profile_type']['button_text'] = array(
'#type' => 'textfield',
'#title' => t('Button text that activates Linkit modal'),
'#default_value' => isset($profile->data['button_text']) ? $profile->data['button_text'] : t('Search'),
'#states' => array(
'visible' => array(
'input[name="profile_type"]' => array(
'value' => LINKIT_PROFILE_TYPE_MENU,
),
),
'required' => array(
'input[name="profile_type"]' => array(
'value' => LINKIT_PROFILE_TYPE_MENU,
),
),
),
'#parents' => array(
'data',
'button_text',
),
);
}