Form constructor.
array $form: An associative array containing the structure of the form.
array $form_state: An associative array containing the current state of the form.
array The form structure.
Overrides ConfigurableActionInterface::form
public function form(array $form, array &$form_state) {
$description = t('The username of the user to which you would like to assign ownership.');
$count = $this->connection
->query("SELECT COUNT(*) FROM {users}")
->fetchField();
$owner_name = '';
if (is_numeric($this->configuration['owner_uid'])) {
$owner_name = $this->connection
->query("SELECT name FROM {users} WHERE uid = :uid", array(
':uid' => $this->configuration['owner_uid'],
))
->fetchField();
}
// Use dropdown for fewer than 200 users; textbox for more than that.
if (intval($count) < 200) {
$options = array();
$result = $this->connection
->query("SELECT uid, name FROM {users} WHERE uid > 0 ORDER BY name");
foreach ($result as $data) {
$options[$data->name] = $data->name;
}
$form['owner_name'] = array(
'#type' => 'select',
'#title' => t('Username'),
'#default_value' => $owner_name,
'#options' => $options,
'#description' => $description,
);
}
else {
$form['owner_name'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#default_value' => $owner_name,
'#autocomplete_path' => 'user/autocomplete',
'#size' => '6',
'#maxlength' => '60',
'#description' => $description,
);
}
return $form;
}