public function CmisBrowserDocumentUploadForm::buildForm in CMIS API 8
Same name and namespace in other branches
- 8.2 src/Form/CmisBrowserDocumentUploadForm.php \Drupal\cmis\Form\CmisBrowserDocumentUploadForm::buildForm()
- 3.0.x src/Form/CmisBrowserDocumentUploadForm.php \Drupal\cmis\Form\CmisBrowserDocumentUploadForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ CmisBrowserDocumentUploadForm.php, line 25
Class
- CmisBrowserDocumentUploadForm
- Class CmisBrowserDocumentUploadForm.
Namespace
Drupal\cmis\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$params = \Drupal::routeMatch();
$directory = file_directory_temp();
$directory_is_writable = is_writable($directory);
if (!$directory_is_writable) {
drupal_set_message($this
->t('The directory %directory is not writable.', [
'%directory' => $directory,
]), 'error');
}
$form['local_file'] = array(
'#type' => 'file',
'#title' => $this
->t('Local file'),
'#description' => $this
->t('Choose the local file to uploading'),
);
$form['description'] = [
'#type' => 'textarea',
'#title' => $this
->t('Document description'),
'#description' => $this
->t('Enter the document description'),
'#default_value' => $form_state
->getValue('description'),
];
$form['config'] = [
'#type' => 'hidden',
'#default_value' => $params
->getParameter('config'),
];
$form['folder_id'] = [
'#type' => 'hidden',
'#default_value' => $params
->getParameter('folder_id'),
];
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Upload'),
);
return $form;
}