Hello
I have a form that I use for both new entries and for editing them.
My question is in the Upload field.
In the editing event, when I don't fill the field, it updates and clears the record that already exists there.
How do I create a condition where, if the field is empty, do not update that column in the table in the database?
Hi rafaelscouto ,
I assume that this is ChronoForms and not ChronoConnectivity?
There is a FAQ on handling File Upload edits, please check that - basically you need to check if the new submission is empty and, if so, remove it from the form data before saving.
Bob
Good morning, I'm using the same CC. Will this FAQ work the same way?
Hi rafaelscouto,
Probably, it may be a bit more complicated, but the same principals should work OK.
Bob
I couldn't make it work for me.
You need to unset the field from the data provider before saving, you can use a PHP action:
$result = $this->data;
if(empty($result['field_name'])){
unset($result['field_name']);
}
return $result;
then use {var:php_name} as the data provider of your save data.
The code assumes that the data provider was initially {data:}
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
It worked for me.
I did a test with a password field, how can I from this code generate a hash?
Hi rafaelscouto,
There is PHP in the Joomla JUser class that can be used to manage password hashes.
Bob
Since I'm not a programmer, it gets harder for me.
I use this code to generate a password hash, but I don't know how to put the two codes together.
$password = $this->data["password"];
$pass = JUserHelper::hashPassword($password);
return $pass;
Hi rafaelscouto,
What exactly do you need to do? And is this using ChronoForms or ChronoConnectivity?
Bob
Hi rafaelscouto,
You won't be saving the password itself so you can combine the two pieces of code in your 'if' statement and either return nothing or return the new hash.
Bob