Skip Navigation

[Resolved] Hidden fields in CRED

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.

Our next available supporter will start replying to tickets in about 0.47 hours from now. Thank you for your understanding.

This topic contains 18 replies, has 3 voices.

Last updated by larryL 7 years, 4 months ago.

Assigned support staff: Caridad.

Author
Posts
#211074

Has their been any progress on getting something like this -

[cred_field field="internal-formtype" type="hidden" post="prm" value="Ambassador" urlparam=""]

to work?

I've seen a few conversations with some suggestions and I tired one suggestion but it did not work.

#211483

Dear Larry,

If internal-formtype a custom field? Otherwise you will need to use a Generic field instead. Generic fields do support the hidden type of field.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#211940

I'm not sure I understand. Are you saying that custom fields are not supported?

How would I use a generic field and make it hidden? If possible, how would I do so with a custom field?

#212216

Hi caridad,

I too am looking for an answer to this question.

best regards...John.

#212233

Actually never mind as I just used some css display: none and it works just as good. cheers..John.

#212234

John, can you elaborate?

#212236
Screen Shot 2014-04-17 at 6.09.01 pm.png

Hi Larry,

As background, I have a motorbike website. When you view a post containing a motorbike and you are logged-in you can click a button titled "I own this" which then adds the bike to the member's virtual garage.

What I did was to embed a CRED form in the post VIEWS template with all fields hidden except for the submit button. (see attached) First, I auto-populated the CRED form and then pruned out everything so that it just contained the form wrapper, messages and the fields themselves as depicted below:

[credform class="cred-form cred-keep-original"]

	[cred_field field="form_messages" value=""]

<div style="display: none;">

		[cred_field field="post_title" post="members-bikes" value="[wpv-post-title]" urlparam=""]
		[cred_field field="bike-id" post="members-bikes" value="[wpv-post-id]" urlparam=""]
		[cred_field field="bike-url" post="members-bikes" value="[wpv-post-url]" urlparam=""]
		
</div>

	[cred_field field="form_submit" value="I own this" urlparam=""]

[/credform]

You can see where I wrapped all the form fields except the submit button in a div with the style set to display:none. You can also see where I have output the current post title as the title for this bike in the member's garage as well as capturing the post URL so that the member can view the bike's specs if needed and also the postID so that I can display a few stats such as xx members own this bike etc.

Hope this helps.

Cheers...John.

#212243

Sorry the image didn't taker for some reason. Link to the image here: hidden link

#212328

John,

This is brilliant in it's simplicity. Do you have a solution for only displaying specific fields based upon a the form used?

Thanks!

Larry

#212385

I'm not sure I understand the question entirely Larry? Can you give me an example?

Thanks....John.

#212386

And actually I owe the solution to the Toolset team who provided this workaround in another post. 🙂

#212389

Say you have a CRED forms called 'widgets', 'tools' and 'money'. All of these forms are part of the same CPT. You create a hidden field called 'form-type' and using your method put it in the form and set the value to the appropriate form (IOW, in the 'widgets' form the value would be 'widgets', etc...)

Now, later on I want to display a new form back to the end user, let's call it 'edit-info'. That form will check the value in field 'form-type' and based upon a condition (my idea) only display the the fields they are supposed to see. Some of them might be read only, some might be editable.

The alternative would be to create an individual CRED (edit) form for each form type but then it does not solve the problem of users who must maintain or act on these forms. I'd have to create another set of CRED forms (maintenance) based upon each form type and then figure out a way to link the edit links based upon form type... you can see this is getting complicated....

🙂

#212409

Because the forms are being embedded inside of a forms template I imagine the conditional logic for this would be handled by wpv-if evaluate statements to test:

a/. for the logged in condition; and
b/. for the relevant form field

Something like:

[wpv-if myFormType="[types field='**form_name**' output='raw'][/types]" evaluate="'[wpv-current-user info="login"]' = '' AND ($myFormType ='Tools') condition='false'"]

<!-- show the tools form fields here -->

[/wpv-if]
[wpv-if myFormType="[types field='**form_name**' output='raw'][/types]" evaluate="'[wpv-current-user info="login"]' = '' AND ($myFormType ='Widgets') condition='false'"]

<!-- show the widgets form fields here -->

[/wpv-if]
[wpv-if myFormType="[types field='**form_name**' output='raw'][/types]" evaluate="'[wpv-current-user info="login"]' = '' AND ($myFormType ='Money') condition='false'"]

<!-- show the money form fields here -->

[/wpv-if]

I haven't validated the above code vis-a-vis correct nesting of quotes etc.

As far as being able to declare some fields read only. This is more difficult and I can't guarantee that my proposed method will work as I haven't tried it. But it would go something like this.

1/. auto generate the creed form and it's fields.
2/. embed the form in a content template
3/. View a post that has the content template applied
4/. Copy all the HTML code for the form concerned from <form> to </form>
5/. Go back to your creed form and overwrite it with the rendered HTML form
6/. Wrap the relevant forms in the appropriate conditional logic as described for above
7/. Set the read only attribute for the relevant form fields that you still wish to be displayed but as read only.
8/. Re fresh the post with the view template applied that has the embedded CRED form
9/. Confirm the form rendered correctly also by looking at view source
10/. Do a test post and see if it takes -- fingers crossed 🙂

Like I said I have no idea if this would work but it would be the first thing I would try.

Alternatively, you could retain the native CRED form and use JavaScript to disable required elements where required. An example is here: hidden link

Just remember that the JS method only works if JS is enabled in the user's browser

Incidentally, read this article here hidden link to determine if you should be using readonly or disabled for your form fields.

Hope this helps.

Cheers...John.

#212418
#212702

Thanks John,

I'm going to give the wpv-if a whirl and see how it goes. I'm not that familiar with javascript so, perhaps foolishly. I'm gonna try this first. I do understand how to build the conditions within the CRED forms but I think what I'm trying to do is much more complex then they anticipated. I'm basically building a CRM from scratch.

Regards,

Larry