I have a problem with my form. At each validation, he created 2 record : the first with the entered data, and the second, empty.
My form is very simple: few input text, select and checkbox (no file).
In onLoad event: i made a custom code :
<?php
$user = \JFactory::getUser();
$form->data['name'] = $user->name;
$form->data['user_id'] = $user->id;
?>
And after the html render form.
On submit event, i do :
1) custom code:
<?php
echo '<pre>';
print_r($form->data);
echo '</pre>';
?>
2) debugger
3) DB save
Enabled: yes
Table: mytable (ok)
save under model id: no
multi: no
model id: data
force save : no
4)Email
To send an email
5)custom code
to display a static message
After the action: i have
Array
(
[chronoform] => contact-interne-FR
[event] => submit
[first_name] => Del Ray
[last_name] => Camillia
[client] => Client
[societe] => Tenebreuse
[pays] => EU
[email] => hugo.schuler@dag-system.com
[phone] => 0625457845
[sujet] => information
[plateforme] => event
[service] => webmaster@dag-system.com
[message] => sqdsqdqsdsqdqsd
[submit6] => Transmettre
[user_id] =>
[name] =>
)
Data Array
Array
(
[chronoform] => contact-FR
[event] => submit
[first_name] => Del Ray
[last_name] => Camillia
[client] => Client
[societe] => Tenebreuse
[pays] => EU
[email] => moi@blzablz.com
[phone] => 0625457845
[sujet] => information
[plateforme] => event
[service] => webmaster@blzablz.com
[message] => sqdsqdqsdsqdqsd
[submit6] => Transmettre
[user_id] =>
[name] =>
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
)
Le rapport est enregistré et transmis au service concerné.
Two questions:
- the user_id and name (hidden fields) is empty but the data were saved in mysql.
- why if i do print_r($form->data) , i have a single record and in debug frame i have two; like in mysql. I don't understand why a empty record was created.
Any idea?