function brightcove_client_form in Brightcove Video Connect 7.7
Same name and namespace in other branches
- 7.6 brightcove.client.inc \brightcove_client_form()
Form callback: create or edit a brightcove client.
Parameters
$client: The client object to edit or for a create form NULL.
File
- ./
brightcove.client.inc, line 204 - Client related code.
Code
function brightcove_client_form($form, &$form_state, $client = NULL) {
$form['label'] = [
'#type' => 'textfield',
'#title' => t('Label'),
'#default_value' => isset($client->label) ? $client->label : '',
'#maxlength' => 128,
'#required' => TRUE,
'#weight' => -10,
];
$form['account_id'] = [
'#type' => 'textfield',
'#title' => t('Brightcove Account id'),
'#default_value' => isset($client->account_id) ? $client->account_id : '',
'#maxlength' => 255,
'#required' => TRUE,
'#weight' => -5,
];
$form['client_id'] = [
'#type' => 'textfield',
'#title' => t('Brightcove API Client id'),
'#default_value' => isset($client->client_id) ? $client->client_id : '',
'#maxlength' => 255,
'#required' => TRUE,
'#weight' => 0,
];
$form['client_secret'] = [
'#type' => 'textfield',
'#title' => t('Brightcove API Client Secret Key'),
'#default_value' => isset($client->client_secret) ? $client->client_secret : '',
'#maxlength' => 255,
'#required' => TRUE,
'#weight' => 5,
];
if (empty($client->is_new)) {
$players = [];
brightcove_try(function () use (&$players, $client) {
foreach (brightcove_player_load_all($client->bcid) as $player) {
$players[$player
->getId()] = $player
->getName();
}
});
$form['default_player'] = [
'#type' => 'select',
'#required' => TRUE,
'#default_value' => brightcove_get_default_player($client->bcid),
'#title' => t('Default player'),
'#options' => $players,
];
}
// When updating a client, do not collapse the Change History fieldset.
$form['change_history'] = [
'#type' => 'fieldset',
'#title' => t('Change history'),
'#collapsible' => TRUE,
'#collapsed' => empty($client->bcid),
'#weight' => 350,
];
$form['change_history']['log'] = [
'#type' => 'textarea',
'#title' => !empty($client->bcid) ? t('Update log message') : t('Creation log message'),
'#rows' => 4,
'#description' => t('Provide an explanation of the changes you are making. This will provide a meaningful history of changes to this client.'),
];
$form['actions'] = [
'#type' => 'actions',
'#weight' => 400,
];
// We add the form's #submit array to this button along with the actual submit
// handler to preserve any submit handlers added by a form callback_wrapper.
$submit = [];
if (!empty($form['#submit'])) {
$submit += $form['#submit'];
}
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save client'),
'#submit' => array_merge($submit, [
'brightcove_client_form_submit',
]),
];
// We append the validate handler to #validate in case a form callback_wrapper
// is used to add validate handlers earlier.
$form['#validate'][] = 'brightcove_client_form_validate';
return $form;
}