public function NodeExportForm::buildForm in Node export 8
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/ NodeExportForm.php, line 24
Class
- NodeExportForm
- Provides a Node Export form.
Namespace
Drupal\node_Export\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Reads the Node id from URL.
$nid = \Drupal::routeMatch()
->getParameter('node');
$json = NodeExport::export([
$nid,
], 'json', FALSE);
$form['export_code'] = [
'#type' => 'textarea',
'#value' => $json,
'#title' => $this
->t('Node Export Code is :'),
'#description' => 'Copy this Code and paste to the import form of new website so as to add these nodes to your new website',
'#rows' => '15',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Download'),
];
$form['nid'] = [
'#type' => 'hidden',
'#value' => $nid,
];
return $form;
}