public function WebformAttachmentUrl::form in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_attachment/src/Plugin/WebformElement/WebformAttachmentUrl.php \Drupal\webform_attachment\Plugin\WebformElement\WebformAttachmentUrl::form()
Gets the actual configuration webform array to be built.
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 An associative array contain the element's configuration webform without any default values.
Overrides WebformAttachmentBase::form
File
- modules/
webform_attachment/ src/ Plugin/ WebformElement/ WebformAttachmentUrl.php, line 42
Class
- WebformAttachmentUrl
- Provides a 'webform_attachment_url' element.
Namespace
Drupal\webform_attachment\Plugin\WebformElementCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['attachment']['url'] = [
'#type' => 'textfield',
'#title' => $this
->t('URL/path'),
'#description' => $this
->t("Make sure the attachment URL/Path is publicly accessible. The attachment's URL/path will never be displayed to end users."),
'#required' => TRUE,
'#element_validate' => [
[
get_class($this),
'validateAttachmentUrl',
],
],
];
if (function_exists('imce_process_url_element')) {
$url_element =& $form['attachment']['url'];
imce_process_url_element($url_element, 'link');
$form['#attached']['library'][] = 'webform/imce.input';
}
return $form;
}