function services_client_ctools_export_ui_form in Services Client 7
Same name and namespace in other branches
- 7.2 services_client.forms.inc \services_client_ctools_export_ui_form()
Define the preset add/edit form.
1 string reference to 'services_client_ctools_export_ui_form'
- services_client.inc in plugins/
export_ui/ services_client.inc
File
- plugins/
export_ui/ services_client.inc, line 86
Code
function services_client_ctools_export_ui_form(&$form, &$form_state) {
// Include the dependent helper
ctools_include('dependent');
$hook =& $form_state['item'];
$breadcrumb = array();
$breadcrumb[] = l(t('Home'), '');
$breadcrumb[] = l(t('Administration'), 'admin');
$breadcrumb[] = l(t('Structure'), 'admin/structure');
$breadcrumb[] = l(t('Services Client'), 'admin/structure/services_client');
// Set Breadcrumbs
drupal_set_breadcrumb($breadcrumb);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#description' => t('The human readable name or description of this connection hook.'),
'#default_value' => $hook->title,
'#required' => true,
);
$form['name'] = array(
'#type' => 'machine_name',
'#title' => t('Machine name'),
'#default_value' => !empty($hook->name) ? $hook->name : '',
'#maxlength' => 32,
'#description' => t('Specify a machine-name for this hook (lowercase and underscores only).'),
'#machine_name' => array(
'exists' => 'services_client_services_connection_hook_exists',
'source' => array(
'title',
),
'label' => t('Machine name'),
'conn_name' => $hook->name,
),
);
// Get all available connections
$connections = services_client_connection_load_all();
$avail_conns = array();
foreach ($connections as $connection) {
$avail_conns[$connection->name] = $connection->name;
}
$form['conn_name'] = array(
'#type' => 'select',
'#title' => t('Connection'),
'#description' => t('Choose the Connection for which to this hook is valid.'),
'#options' => $avail_conns,
'#default_value' => !empty($hook->conn_name) ? $hook->conn_name : '',
'#required' => TRUE,
);
$avail_hooks = array(
'node_save' => 'Node Save',
'node_delete' => 'Node Delete',
'user_save' => 'User Save',
'webform_submission_save' => 'Webform Submission Save',
);
// If we have a value for the hook type ($form['hook']) from $form_state['values'] we use
// this both as the default value for the hook type select list and also as a
// parameter to pass to the function that retrieves the options for the
// plugins.
$default_hook = !empty($hook->hook) ? $hook->hook : key($avail_hooks);
$selected_hook = isset($form_state['values']['hook']) ? $form_state['values']['hook'] : $default_hook;
$form['hook'] = array(
'#type' => 'select',
'#title' => t('Drupal hook'),
'#description' => t('Choose the Drupal hook for which to execute the services connection.'),
'#options' => $avail_hooks,
'#default_value' => $selected_hook,
'#required' => TRUE,
'#ajax' => array(
// When 'event' occurs, Drupal will perform an ajax request in the
// background. Usually the default value is sufficient (eg. change for
// select elements), but valid values include any jQuery event,
// most notably 'mousedown', 'blur', and 'submit'.
'event' => 'change',
'callback' => 'services_client_ajax_callback',
'wrapper' => 'scc-plugins',
),
);
$form['plugins'] = array(
'#tree' => FALSE,
'#prefix' => '<div id="scc-plugins">',
'#suffix' => '</div>',
'#type' => 'item',
);
$form['plugins']['mapping'] = array(
'#type' => 'select',
'#title' => t('Mapping'),
'#options' => services_client_plugin_options('mapping', $selected_hook),
'#description' => t('Select a mapping plugin. Default is node mapping'),
'#default_value' => $hook->config['mapping']['plugin'],
);
$form['plugins']['condition'] = array(
'#type' => 'select',
'#title' => t('Condition'),
'#description' => t('Select a condition plugin. Default is node condition'),
'#options' => services_client_plugin_options('condition', $selected_hook),
'#default_value' => $hook->config['condition']['plugin'],
);
}