public function WSCallTestForm::form in Web Service Data 8
Same name and namespace in other branches
- 2.0.x src/Form/WSCallTestForm.php \Drupal\wsdata\Form\WSCallTestForm::form()
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
1 call to WSCallTestForm::form()
- WSCallTestForm::buildForm in src/
Form/ WSCallTestForm.php - Form constructor.
File
- src/
Form/ WSCallTestForm.php, line 40
Class
- WSCallTestForm
- Class WSCallForm.
Namespace
Drupal\wsdata\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form_state
->disableCache();
$element = $form_state
->getTriggeringElement();
$form['wscallwrapper'] = [
'#type' => 'fieldset',
'#title' => $this
->t('WSCall'),
'title' => [
'#prefix' => '<b>' . $this
->t('Title (Machine name):') . '</b>',
'#markup' => $this->entity
->label() . ' (' . $this->entity
->id() . ')',
],
];
$elements = $this->wsdata
->wscallForm([], $this->entity
->id());
$form['replacements'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Tokens'),
];
$form['replacements']['wscall_form'] = $elements;
// Remove the wscall, we dont need it.
unset($form['replacements']['wscall_form']['wscall']);
if ($element and $element['#id'] == 'call') {
$form['responsewrapper'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Response'),
'response' => [
'#prefix' => '<pre>',
'#markup' => Xss::filter($form_state
->getValue('wscall_response')),
'#suffix' => '</pre>',
],
];
}
return $form;
}