3 function with_usage_in_legacy_form()
7 $form->setId(
'myUniqueFormId');
8 $form->setTitle(
'Form');
10 $form->setPreventDoubleSubmission(
false);
13 $form->addItem($flag);
15 $item->setRequired(
true);
16 $form->addItem($item);
17 $item =
new ilTextareaInputGUI(
'Description',
'description');
18 $item->setRequired(
true);
19 $form->addItem($item);
21 $item->setUploadUrl(
$form->getFormAction());
22 $item->setSuffixes([
'jpg',
'gif',
'png',
'pdf' ]);
23 $item->setInfo(
'Allowed file types: ' . implode(
', ', $item->getSuffixes()));
24 $item->setDropzoneMessage(
'For the purpose of this demo, any PDF file will fail to upload');
25 $form->addItem($item);
26 $form->addCommandButton(
'save',
'Save');
31 if (
$form->checkInput()) {
33 $upload = $DIC->upload();
35 if ($upload->hasUploads()) {
39 $uploadedPDFs = array_filter($upload->getResults(),
function ($uploadResult) {
41 return ($uploadResult->getMimeType() ==
'application/pdf');
43 $uploadResult = count($uploadedPDFs) == 0;
44 echo json_encode(array(
'success' => $uploadResult ));
46 echo json_encode(array(
'success' =>
false ));
51 $form->setValuesByPost();
53 ilUtil::sendSuccess(
'Form processed successfully');
56 return $form->getHTML();
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.