×
Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
How Assign $this->item to current $this->form
Santiago Crespo Calvo - NIF 29159210V
New Member
Posts: 5
1 год 4 мес. назад #10189
от Santiago Crespo Calvo - NIF 29159210V
Santiago Crespo Calvo - NIF 29159210V создал тему: How Assign $this->item to current $this->form
Good morning
I have a component created that when presenting the data of a record in the view if I do a:
var_dump($this->item);
The data retrieved from the database is presented correctly
But if I do var_dump($this->form);
The data of the record that has been previously edited is presented.
That is, in the form variable I have the data from the previously edited record and in the item variable I have the data loaded from the current record.
Can I somehow call a method to reload the form data with the data from $this->item
Thank you.
I have a component created that when presenting the data of a record in the view if I do a:
var_dump($this->item);
The data retrieved from the database is presented correctly
But if I do var_dump($this->form);
The data of the record that has been previously edited is presented.
That is, in the form variable I have the data from the previously edited record and in the item variable I have the data loaded from the current record.
Can I somehow call a method to reload the form data with the data from $this->item
Thank you.
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
Andrew Gonzalez
New Member
Posts: 2
1 год 4 мес. назад - 1 год 4 мес. назад #10192
от Andrew Gonzalez
Andrew Gonzalez ответил в теме How Assign $this->item to current $this->form
Yes, you can assign the data from $this->item to $this->form to reload the form data with the data from the current record. Essentially, you want to synchronize the two variables so that they hold the same data. To achieve this, you can simply copy the data from $this->item to $this->form.
Assuming that $this->item and $this->form are associative arrays, you can do the following: mcdvoice survey
// Copy the data from $this->item to $this->form
$this->form = $this->item;
By doing this, $this->form will now hold the same data as $this->item. Keep in mind that this is a shallow copy, meaning that if your data contains nested arrays or objects, they will be referenced in both $this->item and $this->form. If you need to perform a deep copy, you'll need to implement a custom function to do so.
After executing the above code, you can use var_dump($this->form) to verify that the data in $this->form matches the data in $this->item.
Assuming that $this->item and $this->form are associative arrays, you can do the following: mcdvoice survey
// Copy the data from $this->item to $this->form
$this->form = $this->item;
By doing this, $this->form will now hold the same data as $this->item. Keep in mind that this is a shallow copy, meaning that if your data contains nested arrays or objects, they will be referenced in both $this->item and $this->form. If you need to perform a deep copy, you'll need to implement a custom function to do so.
After executing the above code, you can use var_dump($this->form) to verify that the data in $this->form matches the data in $this->item.
Последнее редактирование: 1 год 4 мес. назад пользователем Andrew Gonzalez.
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
Время создания страницы: 0.048 секунд