function _linkit_build_attribute_plugin_form_fields in Linkit 7.3
Append attribute plugin 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_attribute_plugin_form_fields()
- linkit_profiles_form in plugins/
export_ui/ linkit_profiles.inc - Linkit profile settings form.
File
- plugins/
export_ui/ linkit_profiles.inc, line 360
Code
function _linkit_build_attribute_plugin_form_fields(&$form, LinkitProfile $profile) {
// Load all attribute plugins.
$attributes = linkit_attribute_plugin_load_all();
$form['data']['attribute_plugins_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Attributes'),
'#description' => t('Attributes are HTML attributes that will be attached to
the insert plugin.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => FALSE,
);
$form['data']['attribute_plugins_fieldset']['attribute_plugins'] = array(
'#markup' => '',
'#tree' => TRUE,
'#parents' => array(
'data',
'attribute_plugins',
),
'#theme' => 'linkit_plugin_form_table',
);
// Used to store plugin form elements temporary so we can use this to sort by
// weight later.
$tmp = array();
foreach ($attributes as $name => $attribute) {
$tmp[$name]['name'] = array(
'#markup' => $attribute['name'],
);
$tmp[$name]['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable @title', array(
'@title' => $attribute['name'],
)),
'#title_display' => 'invisible',
'#default_value' => isset($profile->data['attribute_plugins'][$name]['enabled']) ? $profile->data['attribute_plugins'][$name]['enabled'] : FALSE,
);
$tmp[$name]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array(
'@title' => $attribute['name'],
)),
'#title_display' => 'invisible',
'#default_value' => isset($profile->data['attribute_plugins'][$name]['weight']) ? $profile->data['attribute_plugins'][$name]['weight'] : '',
);
}
// Sort by weight.
uasort($tmp, '_linkit_sort_plugins_by_weight_default_value');
foreach ($tmp as $name => $element) {
$form['data']['attribute_plugins_fieldset']['attribute_plugins'][$name] = $element;
}
$form['data']['attribute_plugins_fieldset']['attribute_plugins_info'] = array(
'#markup' => 'Keep in mind that not all attributes can be used by all insert plugins.',
);
}