Forums

Disabled field isn't saved to DB

FenFire 03 Jun, 2014
Hello,
I recently startet to try out chronoforms and already understood a lot. But there are still some questions. I will post them in seperately.
I created a form in which the username should be shown (read from the __users database) for reassurance what will be saved, but the user should not be able to alter it. So I put it on the form as disabled. My problem now is that I want to save the form to a DB and that works well except the name field is left blank. If I use debugger, it's not even in the form array.

Are disabled fields never saved or is there another mistake?
If it's the former, what advice would you give me. Add a hidden 'name' field?

Thanks in advance,
Christian
Max_admin 03 Jun, 2014
Answer
Hi Christian,

Yes, disabled fields are not posted and so their values can't be captured!

If you just want to display it to the user then you can enable the field but write this in the "Extra params" box in your field settings:
readonly=readonly


Another way is to keep the field disabled and drag a custom code action before the "db save" and use this code:

<?php
unset($form->data["field_name_here"]);


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
FenFire 03 Jun, 2014
Nice!
Thanks a lot!
This topic is locked and no more replies can be posted.