Hello, I have a problem that I no longer know how to deal with.
I use view_cell to separate contents that are identical and thus reuse the HTML in a more logical way, the problem I have is that I don't know the reason why one of the view_cells remembers what I have passed to it previously, despite the fact that I am giving it a data clean function. The strange thing is that in another function I do exactly the same and it works without problem.
Thats my view
Code:
...bla, bla, bla...
<fieldset class="" id="order-tasks">
<legend class="fs-6 fw-bolder mt-2 mb-2 border-bottom"><i aria-hidden="true" class="fas fa-tasks me-2"></i><?= lang('App.Task._title') ?></legend>
<div class="d-lg-flex justify-content-between mb-0">
<div class="d-lg-flex justify-content-start flex-grow-1 ms-auto me-lg-2">
<div class="form-floating mb-3 flex-grow-1 me-lg-2 mb-2 mb-lg-0">
<input class="form-control" id="oef-employee" list="employees-registered" type="text" value="">
<label for="oef-employee"><?= lang('App.Employee.fullname') ?></label>
</div>
<div class="form-floating col-lg-3 me-lg-2 mb-2 mb-lg-0">
<select aria-describedby="feedback-required-task-type" class="form-select" id="oef-tasktype">
<?php foreach($datasets['tasks_type'] as $category) : ?>
<option value="<?= $category['IDTaskType'] ?>"><?= $category['Name'] ?></option>
<?php endforeach; ?>
</select>
<label for="oef-tasktype"><?= lang('App.Order.order_type') ?></label>
</div>
<div class="form-floating mb-2 mb-lg-0">
<input class="form-control" id="oef-fetch" name="Fetch" type="date" value="">
<label for="oef-fetch"><?= lang('App.General.fetch') ?></label>
</div>
</div>
<button class="btn btn-primary" id="oef-task-add" type="button"><?= lang('App.Button.include') ?></button>
</div>
<div class="list-group mt-4 mb-4" id="oef-tasks-list">
<?php if (isset($resource['Tasks'])) : foreach (json_decode($resource['Tasks'], true) as $task) : if ($task['IDTask'] !== null) :
echo view_cell('\App\Libraries\ItemLists::order_task', [
'IDTask' => $task['IDTask'],
'IDEmployee' => $task['IDEmployee'],
'IDTaskType' => $task['IDTaskType'],
'Fetch' => $task['TaskFetch'],
'Employee' => $task['Lastname'] .', '. $task['Firstname'],
'Name' => $task['TaskName'],
'Comments' => $task['TaskNotes'],
'Active' => $task['TaskActive'],
'Attachment' => $task['Attachment'],
]);
endif; endforeach; endif; ?>
</div>
... more bla, bla bla...
</fieldset>
<?= $this->endSection() ?>
<?= $this->section('modals') ?>
<?= $this->include('templates/order-vacations-personal-template'); ?>
<?= $this->include('templates/order-default-template'); ?>
<?= view_cell('\App\Libraries\ItemLists::order_equipment_template') ?>
<?= view_cell('\App\Libraries\ItemLists::order_task_template') ?>
<?= $this->endSection() ?>
ItemList.php
PHP Code:
public function equipment_manual(array $data) : String
{
return view('cells/item-equipment-manual', $data);
}
// - -- --- ------------------------------------------------------------
public function equipment_manual_template(array $data) : String
{
return '<template id="equipment_manual_line_template">'. preg_replace('/\s+/', ' ', view('cells/item-equipment-manual', ['data' => [ ]])) .'</template>';
}
// - -- --- ------------------------------------------------------------
public function order_task(array $data) : String
{
return view('cells/item-order-task', $data);
}
// - -- --- ------------------------------------------------------------
public function order_task_template(array $data) : String
{
//return '<template id="order_task_line_template">'. preg_replace('/\s+/', ' ', view('cells/item-order-task')) .'</template>';
return '<template id="order_task_line_template">'. preg_replace('/\s+/', ' ', view('cells/item-order-task', ['data' => [ ]])) .'</template>';
}
// - -- --- ------------------------------------------------------------
And the template file
Code:
<article class="list-group-item list-group-item-action d-lg-flex justify-content-start can-be-filter focus-ring mb-0 p-0" id="task-item-<?= $IDTask ?? 'X' ?>" tabindex="0">
<input id="employee-<?= $IDTask ?? 'X' ?>" name="IDEmployee[]" type="hidden" value="<?= $IDEmployee ?? '' ?>">
<input id="task-type-<?= $IDTask ?? 'X' ?>" name="IDTaskType[]" type="hidden" value="<?= $IDTaskType ?? '' ?>">
<input id="task-date-<?= $IDTask ?? 'X' ?>" name="Fetch[]" type="hidden" value="<?= $Fetch ?? '' ?>">
<div class="d-lg-flex flex-column flex-grow-1 p-2">
<div class="d-lg-flex justify-content-start flex-grow-1">
<p class="flex-grow-1 me-2 mb-1" id="employee-text-<?= $IDTask ?? 'X' ?>"><?= $Employee ?? '' ?></p>
<p class="me-2 mb-1" id="task-type-text-<?= $IDTask ?? 'X' ?>"><?= $Name ?? '' ?></p>
<p class=" mb-1" id="task-date-text-<?= $IDTask ?? 'X' ?>"><?= $Fetch ?? '' ?></p>
</div>
<div class="form-floating col-12 mb-2">
<textarea class="form-control free-height" id="oef-observations-<?= $IDTask ?? 'X' ?>" name="Comments[]" rows="2"><?= $Comments ?? '' ?></textarea>
<label for="oef-observations-<?= $IDTask ?? 'X' ?>"><?= lang('App.General.observations') ?></label>
</div>
</div>
<div class="flex-column d-flex align-items-stretch">
<div class="">
<input autocomplete="off" class="btn-check" id="oef-delete-task-<?= $IDTask ?? 'X' ?>" name="Delete[]" type="checkbox" value="Y">
<label class="btn btn-danger w-100 only-border-top-right delete-label delete-task" data-task="-<?= $IDTask ?? '' ?>" for="oef-delete-task-<?= $IDTask ?? 'X' ?>"><?= lang('App.Button.delete') ?></label>
</div>
<div class="d-flex justify-content-center align-items-center flex-grow-1 pt-2 bg-secondary text-dark bg-opacity-25">
<i aria-label="<?= lang('App.a11y.open') ?>" class="fas fa-lock-open ms-2 me-2"></i>
<div class="form-check form-switch">
<input aria-label="<?= lang('App.a11y.close_task') ?>" <?= (! empty($Active) && ! in_array($Active, ['N', 'F'])) ? '' : 'checked' ?> class="form-check-input" name="Status[]" type="checkbox" role="switch" value="N">
</div>
<i aria-label="<?= lang('App.a11y.close') ?>" class="fas fa-lock me-2"></i>
</div>
<div class="input-group border-0 document-attach-selector <?= (! empty($Attachment) ? 'd-none' : '') ?>" id="document-attach-selector-<?= $IDTask ?? 'X' ?>">
<input class="form-control mask-under-position" id="oef-upload-file-<?= $IDTask ?? 'X' ?>" name="File[]" type="file">
<label class="input-group-text mask-over-position rounded-0 rounded-bottom upload-label" for="oef-upload-file-<?= $IDTask ?? 'X' ?>"><?= lang('App.Button.attach-document') ?></label>
</div>
<div class="input-group border-0 justify-content-end rounded-0 rounded-bottom <?= (empty($Attachment) ? 'd-none' : '') ?> document-attached" id="document-attached-<?= $IDTask ?? 'X' ?>">
<a class="btn bg-secondary text-dark bg-opacity-25 flex-grow-1 only-border-bottom-left" href="$Attachment" target="_blank"><i class="fas fa-file me-2"></i><?= lang('App.Button.see') ?></a>
<button class="btn btn-danger btn-remove-file only-border-bottom-right" type="button"><i class="fas fa-backspace"></i></button>
</div>
</div>
</article>
Any hint of what might be happening, because I'm already going crazy... if I pass it in the array ['IDTask' => null] then it does change to X, in any other way it puts the last identifier that it gives me. I previously went to the ItemList::order_task, and as I mentioned before I don't understand the reason, in the manual part I do exactly the same and there everything is working without problem!
Thanks