/** * {@inheritdoc} * * @see \Drupal\editor\Form\EditorImageDialog * @see editor_image_upload_settings_form() */ public function settingsForm(array $form, array &$form_state, Editor $editor) { form_load_include($form_state, 'inc', 'editor', 'editor.admin'); $form['image_upload'] = editor_image_upload_settings_form($editor); $form['image_upload']['#attached']['library'][] = 'ckeditor/drupal.ckeditor.drupalimage.admin'; $form['image_upload']['#element_validate'][] = array($this, 'validateImageUploadSettings'); return $form; }
/** * {@inheritdoc} */ public function init(FormStateInterface $form_state) { parent::init($form_state); if ($display_id = \Drupal::request()->attributes->get('display_id')) { $this->displayID = $display_id; } // @todo Remove the need for this. form_load_include($form_state, 'inc', 'views_ui', 'admin'); $form_state->set('view', $this->entity); }
/** * Override settings form(). */ public static function settingsForm($field, $instance) { $form = parent::settingsForm($field, $instance); $entity_type = $field['settings']['target_type']; $entity_info = entity_get_info($entity_type); $bundles = array(); foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { if (og_is_group_type($entity_type, $bundle_name)) { $bundles[$bundle_name] = $bundle_info['label']; } } if (!$bundles) { $form['target_bundles'] = array('#type' => 'item', '#title' => t('Target bundles'), '#markup' => t('Error: The selected "Target type" %entity does not have bundles that are a group type', array('%entity' => $entity_info['label']))); } else { $settings = $field['settings']['handler_settings']; $settings += array('target_bundles' => array(), 'membership_type' => OG_MEMBERSHIP_TYPE_DEFAULT, 'reference_type' => 'my_groups', 'primary_field' => FALSE, 'hide_secondary_field' => TRUE); $form['target_bundles'] = array('#type' => 'select', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => $settings['target_bundles'], '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type acting as group, that can be referenced. Optional, leave empty for all bundles.')); $options = array(); foreach (og_membership_type_load() as $og_membership) { $options[$og_membership->name] = $og_membership->description; } $form['membership_type'] = array('#type' => 'select', '#title' => t('OG membership type'), '#description' => t('Select the membership type that will be used for a subscribing user.'), '#options' => $options, '#default_value' => $settings['membership_type'], '#required' => TRUE); $form['reference_type'] = array('#type' => 'select', '#title' => t('Reference'), '#options' => array('my_groups' => t('My groups'), 'other_groups' => t('Other groups'), 'all_groups' => t('All groups')), '#description' => t('What groups should be referenced.'), '#default_value' => $settings['reference_type']); $options = array('0' => t('None')); // Get all the other group audience fields in this bundle. $entity_type = $instance['entity_type']; $bundle = $instance['bundle']; $fields_info = field_info_fields(); foreach (field_info_instances($entity_type, $bundle) as $field_name => $field_instance) { if ($field_name == $field['field_name']) { // This is the current field. continue; } if ($fields_info[$field_name]['type'] != 'entityreference' || $fields_info[$field_name]['settings']['handler'] != 'og') { // This is not an Entity reference field. continue; } if (!empty($fields_info[$field_name]['settings']['handler_settings']['primary_field'])) { // Field is already a secondary field. continue; } $options[$field_name] = $field_instance['label'] . ' (' . $field_name . ')'; } $form['primary_field'] = array('#type' => 'select', '#title' => t('Primary field'), '#description' => t('Select a field that will be populated with the values of this field.'), '#options' => $options, '#default_value' => $settings['primary_field'], '#required' => TRUE, '#element_validate' => array('og_handler_primary_field_validate')); $form['hide_secondary_field'] = array('#type' => 'checkbox', '#title' => t('Hide secondary field'), '#description' => t('Show the secondary field only to users with "administer group" permission.'), '#default_value' => $settings['hide_secondary_field'], '#states' => array('invisible' => array(':input[name="field[settings][handler_settings][primary_field]"]' => array('value' => 0)))); form_load_include($form_state, 'php', 'og', '/plugins/selection/og.class'); } return $form; }
/** * Form to configure a visibility rule. */ function panels_edit_configure_access_test_form($form, &$form_state) { ctools_form_include($form_state, 'plugins', 'panels'); form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class'); $display =& $form_state['display']; $test =& $form_state['test']; $plugin =& $form_state['plugin']; $form['#action'] = $form_state['url']; $contexts = $display->context; if (!isset($contexts['logged-in-user'])) { $contexts['logged-in-user'] = ctools_access_get_loggedin_context(); } if (isset($plugin['required context'])) { $form['context'] = ctools_context_selector($contexts, $plugin['required context'], $test['context']); } $form['settings'] = array('#tree' => TRUE); if ($function = ctools_plugin_get_function($plugin, 'settings form')) { $form = $function($form, $form_state, $test['settings']); } $form['not'] = array('#type' => 'checkbox', '#title' => t('Reverse (NOT)'), '#default_value' => !empty($test['not'])); $form['save'] = array('#type' => 'submit', '#value' => t('Save')); $form['remove'] = array('#type' => 'submit', '#value' => t('Remove'), '#remove' => TRUE); return $form; }
/** * Include the file. Internally this uses file_load_include() function. * * @param string $type * Type of file. This is usually the file extension. * @param string $module * Module name where the file is present. * @param null|string $name * Base file name without the extension. If this is omitted, then $module * is used instead. */ public function includeFile($type, $module, $name = NULL) { form_load_include($this->form_state, $type, $module, $name); }
/** * Add all appropriate includes to forms so that caching the form * still loads the files that we need. */ function _entityqueue_export_ui_add_form_files($form, &$form_state) { ctools_form_include($form_state, 'export'); ctools_form_include($form_state, 'export-ui'); // Also make sure the plugin .inc and .class.php files are loaded. form_load_include($form_state, 'inc', 'entityqueue', '/plugins/ctools/export_ui/entityqueue_export_ui'); form_load_include($form_state, 'php', 'entityqueue', '/plugins/ctools/export_ui/entityqueue_export_ui.class'); }