ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclFileFieldRepresentation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public function getInputField(
25 ?int $record_id = null
27 $input = new ilFileInputGUI(
28 $this->getField()->getTitle(),
29 'field_' . $this->getField()->getId()
30 );
31
32 $supported_suffixes = $this->getField()->getSupportedExtensions();
33 if (!empty($supported_suffixes)) {
34 $input->setSuffixes($supported_suffixes);
35 }
36
37 $input->setAllowDeletion(true);
38 $this->requiredWorkaroundForInputField($input, $record_id); // TODO CHeck
39
40 return $input;
41 }
42
44 ilFileInputGUI $input,
45 ?int $record_id
46 ): void {
47 if ($record_id !== null) {
48 $record = ilDclCache::getRecordCache($record_id);
49 }
50
51 $this->setupInputField($input, $this->getField());
52
53 //WORKAROUND
54 // If field is from type file: if it's required but already has a value it is no longer required as the old value is taken as default without the form knowing about it.
55 if ($record_id !== null && $record->getId()) {
56 $field_value = $record->getRecordFieldValue($this->getField()->getId());
57 if ($field_value) {
58 $input->setRequired(false);
59 }
60 }
61 // If this is an ajax request to return the form, input files are currently not supported
62 if ($this->ctrl->isAsynch()) {
63 $input->setDisabled(true);
64 }
65 }
66
67 protected function buildFieldCreationInput(
69 string $mode = 'create'
70 ): ilRadioOption {
71 $opt = parent::buildFieldCreationInput($dcl, $mode);
72
73 $prop_filetype = new ilTextInputGUI(
74 $this->lng->txt('dcl_supported_filetypes'),
76 );
77 $prop_filetype->setInfo($this->lng->txt('dcl_supported_filetypes_desc'));
78
79 $opt->addSubItem($prop_filetype);
80
81 return $opt;
82 }
83}
static getRecordCache(?int $record_id)
getInputField(ilPropertyFormGUI $form, ?int $record_id=null)
Returns field-input.
buildFieldCreationInput(ilObjDataCollection $dcl, string $mode='create')
Build the creation-input-field.
requiredWorkaroundForInputField(ilFileInputGUI $input, ?int $record_id)
This class represents a file property in a property form.
This class represents a property form user interface.
This class represents an option in a radio group.
This class represents a text property in a property form.
if(!file_exists('../ilias.ini.php'))