Hello,
I've designed a form for updating a database table. It works. The problem is that I can't add a new record through this form. I tried creating a link to the form with the parameter `chronopage=edit` to call it and without an `id` parameter, but the form isn't blank ; it's already populated with the data from the previous open record. Would it be better to create a separate form for adding records ?
Thank you for your insights.
Hi
You need a PHP action at the start of the page to check if the "id" parameter exists or not, if it exists then Read Data, if not then do nothing
You can use the PHP Events behavior for that.
Let me know if you need a screenshot
Hi Max,
Thanks for your response. I begin like this but, yes, I need a sreenshot of what it should be made

Here is how it should look like:

and here is the code:
if(!empty($this->data("id"))){
return "read";
}else{
return "blank";
}
You check $this->data because id will be passed as a query parameter in the form URL
Unfortunately it still doesn't work, my form is still not blank, it is still completed with data from the previous record consulted.I attach a capture (two pictures) for a better evaluation of the pb.


Hi
Try to add the Clear Session action at the start of the editing page:

Does this help ?
According to your image the reading will only happen when the "id" parameter is passed, but once you read it and the data is merged, the data will not be reset until the editing page is submitted, and if you do not do that then the data will stay there.
Hi Max,
Unfortunately, it's still not working. The creation form displays the last viewed record. Can I send you a backup of the form for analysis ? How ?
Thanks a lot.
Hi CDLMQSE
Instead of the Clear Session action, please try a PHP action with this code:
$this->data=[];
Add this action in the "blank" event of the PHP which checks for "id", you can also add that line in the main PHP itself inside the "blank" branch
What do you get ?
