Forums

dynamically set a field to readonly if the value fetched from Db is not null

rasheed1011 12 Aug, 2020
How do I dynamically set a field to readonly if the value fetched from Db is not null .

I am fetching email field value from DB. if the value for this is field is not null then I want the field to be readonly. that means it should only display the email id. if the value returned from the DB is null then the user should have option to enter the value for email id which will be updated in DB for future use.

Kindly suggest how this can be achieved.

TIA
GreyHead 13 Aug, 2020
HI rasheed1011,

You can use an Event Switcher in the form On Load action to change the CSS for that input. I suggest that you disable the input if the data exists rather than make it readonly as disabled inputs do not submit values.

Bob
rasheed1011 14 Aug, 2020
disabling is not syncing the value in DB.
GreyHead 14 Aug, 2020
Hi rasheed1011,

If there is no value for that item then the DB record for that item should be unchanged. By all means use the readonly setting instead though.

Bob
Max_admin 16 Aug, 2020
you better use 2 fields, one with readonly attribute another without, and switch them based on the db value!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.