Hi,
In my form there are several "choices" in a drop down menu: For Example:
a person can choose between (werkstatus) "werkloos", "deeltijds", "voltijds".
Tnx,
Bart Weltens
Belgium
In my form there are several "choices" in a drop down menu: For Example:
a person can choose between (werkstatus) "werkloos", "deeltijds", "voltijds".
- If they choose "werkloos" another item (wens) is shown and people can choose between "wil werk" and "wil geen werk". In that case al other earlier choices stored in a DB (such as "opdrachtbreuk" or "wanneer") have to bedeleted.
- If they choose "deeltijds" then they get another a question "hoeveel uur werk u?" and also "wil u meer werk?"
- If they choose "voltijds" then they get a question: "wanneer ben u terug beschikbaar?" In this case al other earlier choices stored in a DB (such as "opdrachtbreuk" or "wanneer") have to bedeleted.
Tnx,
Bart Weltens
Belgium
Hi Bart,
Yes, you can do that. It will probably take a bit of custom coding in the On Submit event to make sure that you are saving the 'correct' new data.
Bob
Yes, you can do that. It will probably take a bit of custom coding in the On Submit event to make sure that you are saving the 'correct' new data.
Bob
Hi Bob,
Any idea on how to do the coding?
I don't have a clue on how to do that.
Can you give me a hint on what code I should use?
tnx,
Bart Weltens
Any idea on how to do the coding?
I don't have a clue on how to do that.
Can you give me a hint on what code I should use?
tnx,
Bart Weltens
Hi Bart,
Not from the info that you have posted here.
If you add a Debugger action near the start of the on Submit event (after any spam checks and validation and your Read Data action) then you can see exactly what data is being submitted and work out the exact logic that needs to be applied before you save/update the record .
Bob
Not from the info that you have posted here.
If you add a Debugger action near the start of the on Submit event (after any spam checks and validation and your Read Data action) then you can see exactly what data is being submitted and work out the exact logic that needs to be applied before you save/update the record .
Bob
Hi Bob,
This is the debugger info:
The [opdrachtbreuk] was hidden in the form due to the choice in [werkstatus]= voltijds. But it was read from the DB in an earlier formsubmit.
The same goes for [uitbreiding] and [halve_dagen].
This is the debugger info:
The [opdrachtbreuk] was hidden in the form due to the choice in [werkstatus]= voltijds. But it was read from the DB in an earlier formsubmit.
The same goes for [uitbreiding] and [halve_dagen].
Array ( [option] => com_chronoforms6 [view] => form [Itemid] => 203 [chronoform] => melding-tijdelijke-copy [event] => submit [naam] => Testpersoon [email] => ict@deachellier.be [telefoon] => 0476543159 [woonplaats] => Koersel [diploma] => onderwijzer, opleiding preventieadviseur niveau 3 [CV] => [ambt_aanstelling] => onderwijzer [bijkomend_ambt] => Array ( [0] => kleuteronderwijzer [1] => ICT ) [werkstatus] => voltijds [opdrachtbreuk] => 18/36 [uitbreiding] => uitbreiding [halve_dagen] => Array ( [0] => MA-VM [1] => DI-VM [2] => WOE-VM ) [geldigheid] => 2019-06-30 [vragen] => Dit is een voorbeeldopmerking. [akkoord] => Akkoord met de privacyregels van KBHA vzw [verstuur] => )
Array ( [validate_fields2] => Array ( [log] => Automatic validation enabled. [var] => 1 ) [save_data9] => Array ( [data] => Array ( [created] => 2018-11-01 20:39:40 [modified] => 2018-11-01 20:39:40 [user_id] => 887 [naam] => Testpersoon [email] => ict@deachellier.be [telefoon] => 0476543159 [woonplaats] => Koersel [diploma] => onderwijzer, opleiding preventieadviseur niveau 3 [CV] => [ambt_aanstelling] => onderwijzer [bijkomend_ambt] => ["kleuteronderwijzer","ICT"] [werkstatus] => voltijds [opdrachtbreuk] => 18/36 [uitbreiding] => uitbreiding [halve_dagen] => ["MA-VM","DI-VM","WOE-VM"] [geldigheid] => 2019-06-30 [vragen] => Dit is een voorbeeldopmerking. [akkoord] => Akkoord met de privacyregels van KBHA vzw ) [_success] => Gegevens met succes opgeslagen [log] => Array ( [0] => INSERT INTO `hi08h_chronoforms_data_melding-tijdelijke` (`created`, `modified`, `user_id`, `naam`, `email`, `telefoon`, `woonplaats`, `diploma`, `CV`, `ambt_aanstelling`, `bijkomend_ambt`, `werkstatus`, `opdrachtbreuk`, `uitbreiding`, `halve_dagen`, `geldigheid`, `vragen`, `akkoord`) values ('2018-11-01 20:39:40', '2018-11-01 20:39:40', '887', 'Testpersoon', 'ict@deachellier.be', '0476543159', 'Koersel', 'onderwijzer, opleiding preventieadviseur niveau 3', '', 'onderwijzer', '["kleuteronderwijzer","ICT"]', 'voltijds', '18/36', 'uitbreiding', '["MA-VM","DI-VM","WOE-VM"]', '2019-06-30', 'Dit is een voorbeeldopmerking.', 'Akkoord met de privacyregels van KBHA vzw') ON DUPLICATE KEY UPDATE `created` = '2018-11-01 20:39:40',`modified` = '2018-11-01 20:39:40',`user_id` = '887',`naam` = 'Testpersoon',`email` = 'ict@deachellier.be',`telefoon` = '0476543159',`woonplaats` = 'Koersel',`diploma` = 'onderwijzer, opleiding preventieadviseur niveau 3',`CV` = '',`ambt_aanstelling` = 'onderwijzer',`bijkomend_ambt` = '["kleuteronderwijzer","ICT"]',`werkstatus` = 'voltijds',`opdrachtbreuk` = '18/36',`uitbreiding` = 'uitbreiding',`halve_dagen` = '["MA-VM","DI-VM","WOE-VM"]',`geldigheid` = '2019-06-30',`vragen` = 'Dit is een voorbeeldopmerking.',`akkoord` = 'Akkoord met de privacyregels van KBHA vzw'; ) [var] => Array ( [created] => 2018-11-01 20:39:40 [modified] => 2018-11-01 20:39:40 [user_id] => 887 [naam] => Testpersoon [email] => ict@deachellier.be [telefoon] => 0476543159 [woonplaats] => Koersel [diploma] => onderwijzer, opleiding preventieadviseur niveau 3 [CV] => [ambt_aanstelling] => onderwijzer [bijkomend_ambt] => ["kleuteronderwijzer","ICT"] [werkstatus] => voltijds [opdrachtbreuk] => 18/36 [uitbreiding] => uitbreiding [halve_dagen] => ["MA-VM","DI-VM","WOE-VM"] [geldigheid] => 2019-06-30 [vragen] => Dit is een voorbeeldopmerking. [akkoord] => Akkoord met de privacyregels van KBHA vzw ) ) [upload15] => Array ( [path] => /var/www/clients/client27229/web44687/web/personeelsdatabank/components/com_chronoforms6/chronoforms/uploads/CV/ [CV] => Array ( [extensions] => Array ( [0] => pdf ) [info] => File is not present. ) [var] => Array ( ) ) )
How do you know which entries in the database are "earlier" and need to be deleted?
Hi,
Every user logs in and can update its work status.
When the user loads the form, the earlier data is loaded form the db.
The user can change the items in the preloaded form.
Every user logs in and can update its work status.
When the user loads the form, the earlier data is loaded form the db.
The user can change the items in the preloaded form.
So are you just updating existing data, or is there a "delete everything" dropdown option or something?
Just updating existing data. But when there is a choice made in a dropdown, other data wich is not applicable has to be deleted.
ex. [opdrachtbreuk] is in the DB "18/36" but it has to be deleted when in the dropdow is chosen for [werkstatus]=voltijds.
ex. [opdrachtbreuk] is in the DB "18/36" but it has to be deleted when in the dropdow is chosen for [werkstatus]=voltijds.
So you're not deleting a row you're just setting a column to null or empty?
Couple ways of doing it. If you only have a few dropdowns, you can use a switch. Data source: {data:dropdown_name}
Then you have
In your database save action, you have :
Or if you have a whole bunch of them you can use a PHP block.
Few other ways to do it, but there you go.
Then you have
no:{data:field_value}Where "no" is the value sent by your dropdown when you DON'T want it deleted.
In your database save action, you have :
field:{var:switch_name}That way if the dropdown says to delete, the switch will have an empty value. If it's set to NOT delete then it will send the data value.
Or if you have a whole bunch of them you can use a PHP block.
$array = [];Then in your save data ction
$array["field1"] = ($this->data("delete_field1") == 'yes' ? null : $this->data("field1"));
// Repeat for all fields
return $array
field:{var:php_name.field1}
field2:{var:php_name.field2}
Few other ways to do it, but there you go.
This topic is locked and no more replies can be posted.