action_example_node_sticky_action_form

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 action_example_node_sticky_action_form($context)

Generates settings form for action_example_node_sticky_action().

Parameters

$context An array of options of this action (in case it is being edited)

Return value

array $form

See also

action_example_action_info()

Related topics

Code

examples/action_example/action_example.module, line 285

<?php
function action_example_node_sticky_action_form($context) {
  /*
   * We return a configuration form to set the requirements that will
   * match this action before being executed. This is a regular Drupal form and
   * may include any type of information you want, but all the fields of the
   * form will be saved into the $context variable.
   *
   * In this case we are promoting all content types submitted by this user, but
   * it is possible to extend these conditions providing more options in the
   * settings form.
   */
  $form['author'] = array(
    '#title' => t('Author name'), 
    '#type' => 'textfield', 
    '#description' => t('Any content created, presaved or updated by this user will be promoted to front page and set as sticky.'), 
    '#default_value' => isset($context['author']) ? $context['author'] : '',
  );
  // Verify user permissions and provide an easier way to fill this field.
  if (user_access('access user profiles')) {
    $form['author']['#autocomplete_path'] = 'user/autocomplete';
  }
  // No more options, return the form.
  return $form;
}
?>