/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $entity_type_id = $this->definition['entity_type']; // Derivative IDs are all entity:entity_type. Sanitized for js. // The ID is converted back on submission. $sanitized_id = ArgumentPluginBase::encodeValidatorId($this->definition['id']); $entity_type = $this->entityManager->getDefinition($entity_type_id); // If the entity has bundles, allow option to restrict to bundle(s). if ($entity_type->hasKey('bundle')) { $bundle_options = array(); foreach ($this->entityManager->getBundleInfo($entity_type_id) as $bundle_id => $bundle_info) { $bundle_options[$bundle_id] = $bundle_info['label']; } $form['bundles'] = array('#title' => $entity_type->getBundleLabel() ?: $this->t('Bundles'), '#default_value' => $this->options['bundles'], '#type' => 'checkboxes', '#options' => $bundle_options, '#description' => $this->t('If none are selected, all are allowed.')); } // Offer the option to filter by access to the entity in the argument. $form['access'] = array('#type' => 'checkbox', '#title' => $this->t('Validate user has access to the %name', array('%name' => $entity_type->getLabel())), '#default_value' => $this->options['access']); $form['operation'] = array('#type' => 'radios', '#title' => $this->t('Access operation to check'), '#options' => array('view' => $this->t('View'), 'update' => $this->t('Edit'), 'delete' => $this->t('Delete')), '#default_value' => $this->options['operation'], '#states' => array('visible' => array(':input[name="options[validate][options][' . $sanitized_id . '][access]"]' => array('checked' => TRUE)))); // If class is multiple capable give the option to validate single/multiple. if ($this->multipleCapable) { $form['multiple'] = array('#type' => 'radios', '#title' => $this->t('Multiple arguments'), '#options' => array(0 => $this->t('Single ID', array('%type' => $entity_type->getLabel())), 1 => $this->t('One or more IDs separated by , or +', array('%type' => $entity_type->getLabel()))), '#default_value' => (string) $this->options['multiple']); } }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Build the list of all permissions grouped by module. $permissions = []; foreach ($this->permissionHandler->getPermissions() as $permission => $permission_item) { $provider = $permission_item['provider']; $display_name = $this->moduleHandler->getName($provider); $permissions[$display_name][$permission] = Html::escape($permission_item['title']); } $form['admin_permission'] = ['#type' => 'select', '#title' => $this->t('Admin permission'), '#description' => $this->t('Allows the current user to access the view even if the argument is a different user.'), '#options' => $permissions, '#empty_value' => '', '#default_value' => $this->options['admin_permission']]; }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if (!isset($this->argument_wrapper)) { return; } // We can't set default in defineOptions because argument is not set yet. if ($this->options['replacement_format']) { $default = $this->options['replacement_format']; } else { $default = $this->getDefaultReplacementFormat(); } $form['replacement_format'] = ['#type' => 'textfield', '#title' => $this->t('Replacement date pattern'), '#default_value' => $default, '#description' => $this->t('Provide a date pattern to be used when replace this arguments as a title.')]; }