67 $this->item_facade = $item;
69 if (!$this->item_facade->isEmpty()) {
80 $txt =
function (
$id) :
string {
81 return $this->lng->txt(
$id);
83 $f =
function () : InputFactory {
84 return $this->ui_fa->input();
87 $title =
$f()->field()->text(
$txt(
'sub_title_default'),
$txt(
'sub_title_default_byline'));
88 if (!$this->item_facade->isEmpty()) {
89 $title =
$title->withValue($this->item_facade->getDefaultTitle());
91 $items[self::F_TITLE] =
$title;
94 $type =
$f()->field()->radio(
$txt(
'sub_type'),
$txt(
'sub_type_byline'))->withRequired(
true);
95 $type_informations = $this->
repository->getPossibleSubItemTypesWithInformation();
97 foreach ($type_informations as $classname => $information) {
98 if ($this->item_facade->isEmpty()
99 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType() && $this->item_facade->isCustom())
101 $inputs = $this->
repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
102 $type =
$type->withOption($this->
hash($classname), $information->getTypeNameForPresentation(), $information->getTypeBylineForPresentation(), $inputs);
106 if (!$this->item_facade->isEmpty() && $this->item_facade->isCustom()) {
107 $type =
$type->withValue($this->
hash($this->item_facade->getType()));
108 } elseif ($this->item_facade->isCustom()) {
109 $type =
$type->withValue($this->
hash(reset(array_keys($type_informations))));
112 if ($this->item_facade->isEmpty() || $this->item_facade->isCustom()) {
113 $items[self::F_TYPE] =
$type;
117 $parent =
$f()->field()->select(
$txt(
'sub_parent'), $this->
repository->getPossibleParentsForFormAndTable())
118 ->withRequired(
true);
119 if (!$this->item_facade->isEmpty() && !$this->item_facade->isInLostItem()) {
120 $parent = $parent->withValue($this->item_facade->getParentIdentificationString());
122 $parent = $parent->withValue(reset(array_keys($this->
repository->getPossibleParentsForFormAndTable())));
124 $items[self::F_PARENT] = $parent;
127 $active =
$f()->field()->checkbox(
$txt(
'sub_active'),
$txt(
'sub_active_byline'));
128 if (!$this->item_facade->isEmpty()) {
129 $active = $active->withValue($this->item_facade->isAvailable());
131 $items[self::F_ACTIVE] = $active;
134 if ($this->item_facade->isEmpty()) {
136 $this->form =
$f()->container()->form()
140 $this->form =
$f()->container()->form()
150 $this->form = $this->form->withRequest($DIC->http()->request());
151 $data = $this->form->getData();
153 if (is_null(
$data)) {
157 $this->item_facade->setAction((
string)
$data[0][
'action']);
158 $this->item_facade->setDefaultTitle((
string) $data[0][self::F_TITLE]);
159 $this->item_facade->setActiveStatus((
bool) $data[0][self::F_ACTIVE]);
160 if ((
string) $data[0][self::F_PARENT]) {
161 $this->item_facade->setParent((
string) $data[0][self::F_PARENT]);
163 $this->item_facade->setIsTopItm(
false);
165 if ($this->item_facade->isEmpty()) {
166 $type = $this->unhash((
string) ($data[0][self::F_TYPE][
'value']));
167 $this->item_facade->setType(
$type);
168 $r->createItem($this->item_facade);
170 if ($this->item_facade->isCustom()) {
171 $type = $this->item_facade->getType();
172 $type_specific_data = (array) $data[0][self::F_TYPE][
'group_values'];
174 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
177 $r->updateItem($this->item_facade);
185 return $this->ui_re->render([$this->form]);
An entity that renders components to a string output.
This class provides processing control methods.
if(!array_key_exists('StateId', $_REQUEST)) $id
Class ilMMItemRepository.
This is how the factory for UI elements looks.
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
Interface ilMMItemFacadeInterface.