Skip Navigation

[Resolved] Read-only cred forms

This thread is resolved. Here is a description of the problem and solution.

Problem: When certain Users visit the CRED form, it should be displayed as "read-only". Other Users should see the standard CRED form.

Solution: There's not an easy way to do this with CRED, because the readonly attribute does not apply to all kinds of fields. Instead, you could use Access to hide the entire CRED form and show something else in its place. For instance, you could show a View that displays the post and custom field information in text format. If you want to format that information to look like a read-only form, it will require custom code.

Relevant Documentation: https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#618201

I am trying to:

To set a credform tot readonly for logging in users.

When a user with the role 'werkgever' is logged in the available forms most be read only. They ca only be edited by administrators. I can't find that in acces en when I set the CRED fields to read only I cannot set the radiobuttons tot readonly.

Link to a page where the issue can be seen:

I expected to see:

Instead, I got:

#618438

Hi, the "readonly" attribute only works on text-based input fields, not checkboxes or radios. You can find that information in our documentation here:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

When a user with the role 'werkgever' is logged in the available forms most be read only.
There's not an easy way to do this with CRED, because the readonly attribute does not apply to all kinds of fields. Instead, you could use Access to hide the entire CRED form and show something else in its place. For instance, you could show a View that displays the post and custom field information in text format. If you want to format that information to look like a read-only form, it will require custom code.

#618554
Schermafdruk 2018-02-22 09.45.07.png

Hi Christian,

Thanks for your reply!!

Is are very big forms with a lot of data. Is there a way to make a view with all the data at once?

Is there a way to show the forms tot a user with the role 'werkgever' where his edits don't save (not editable)

Is there a way to quick make a layout for the view. I use Bever Themes but I can use Layouts from types.

Jacques

#618780

Is there a way to make a view with all the data at once?
There is no feature to automatically create a View with all the data fields in place. If you want to mimic the CRED form design, you can create another Edit CRED form and replace the cred_field shortcodes with custom field shortcodes. This is probably the fastest way to create a similar design. Then you can use Access Controls to show this modified form to "werkgever" Users, and show the regular Edit CRED form to other Users.

Is there a way to show the forms tot a user with the role 'werkgever' where his edits don't save (not editable)
You could use inline Access Controls to wrap the "submit" button in a conditional that hides the button from all "werkgever" users. This is not foolproof, so you should add some backend validation enforcement using the cred_form_validate API:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

Is there a way to quick make a layout for the view. I use Bever Themes but I can use Layouts from types.
There is no quick way to create a Layout that includes all the information you would find in a CRED form. Each field must be added to a View or Visual Editor cell to appear in the Layout.