Open aerni opened 2 years ago
Oh interesting. Could we get more info on your use case?
I'll whip up a repo.
Here you go: https://github.com/aerni/hidden-form-fields.
Just create a super user and navigate to the contact form.
All fields are visible in the submission listing view:
But not all of them are visible in the individual submission view:
I've got an event sign-up form. To identify which event a user signed up for, I'm passing the event ID as a hidden form input. The CP user should be able to see all submitted data, no matter the visibility of the field on the frontend. I'm using my Livewire Forms addon. The addon picks up the visibility state of the field to determine if a field should be hidden on the frontend. Same goes for the Hidden
fieldtype.
I have a similar use case as above, but wanted to add that if you have the field as Visible but change the html5 Input Type to 'hidden' it results in a similar issue with just the field label showing and the input field not. I would expect the submission detail to show the field even though its input type is 'hidden' (which would be for the front end form output).
If you give a field a visibility of hidden, it should be hidden in the CP. That's the point of it. Seems like it's working correctly to me.
There may be a disconnect with the use case in frontend forms though. Need a way to make a field hidden in the frontend but not in the cp.
Your repo doesn't show how you're using the form and fields on the front end though, unless I'm missing something.
My use case is we have a a collection of events, and on each event detail page is a registration form, we have a hidden field (hidden by selecting the 'hidden' html5 input type): which is populated with the event date from the collection entry so that when a registration form is submitted it also includes the date that the end user has registered on.
But in the submission detail in the CP the event date label shows but the field and value dont:
I would have thought that the input type should ONLY apply to front end, which would leave the Visibility field to control the CP side. Currently there is no way to create a hidden field on the frontend, while maintaining the ability to see it in the submission.
I'm more talking about Michael's situation.
In your case, I'm honestly not even sure why a hidden input type even exists. 😊 Selecting the "input type" makes sense for all types except hidden.
Okay looking back at the git history, we added the option to set the input type to hidden literally for forms on the frontend. Maybe that was merged a little hastily, because while it makes sense on the frontend, once you go back to the CP to view the submission, it would also be hidden. #2952
After some internal discussion, we're thinking of possibly removing input_type: hidden
on the text field altogether, since it's an input type that was only added for frontend forms, but obviously confusing and broken in the submission view.
For the use cases mentioned above, if you use input_type: text
it'll be visible in the form submission in the CP, and you can still control visibility/rendering in your html markup...
{{ form:contact }}
{{ fields }}
{{ if handle == "event_name" }}
<input name="event_name" type="hidden" value="{{ event_name }}">
{{ elseif handle == "event_date" }}
<input name="event_date" type="hidden" value="{{ event_date }}">
{{ else }}
<label>{{ display }}</label>
<div class="p-1">{{ field }}</div>
{{ /if }}
{{ /fields }}
<button>Submit</button>
{{ /form:contact }}
There may be a disconnect with the use case in frontend forms though. Need a way to make a field hidden in the frontend but not in the cp.
Yes, you're right. Visibility is working as expected but doesn't make much sense for form submissions. I'm probably "abusing" the visibility to build my frontend forms.
Your repo doesn't show how you're using the form and fields on the front end though, unless I'm missing something.
I didn't add this as I'm using my Livewire Forms addon. I'm basically using the visibility of a field to hide input fields. That's it.
I generally think that the main issue with fieldtypes in the form builder is the disconnect between CP and frontend. Like the duplicate
and mode
options of the asset fieldtype. They don't make much sense in the context of forms.
Anyhow, I think the easy solution for my problem would be to simply show fields with visibility hidden in the form submissions. Or else remove the visibility options for forms to not confuse the users. (Except if you're still thinking about adding computed fields to forms at some point, like mentioned over here: https://github.com/statamic/ideas/issues/834.)
I wouldn't drop the use of an input type hidden. It would be a shame to have to do this based on handles. Why not setting all input fields to text in the CP submission? They're "read only", so the functionality behind the type is gone anyway.
I know it's an old thread, but we're running into similar problems.
After some internal discussion, we're thinking of possibly removing
input_type: hidden
on the text field altogether, since it's an input type that was only added for frontend forms, but obviously confusing and broken in the submission view.For the use cases mentioned above, if you use
input_type: text
it'll be visible in the form submission in the CP, and you can still control visibility/rendering in your html markup...{{ form:contact }} {{ fields }} {{ if handle == "event_name" }} <input name="event_name" type="hidden" value="{{ event_name }}"> {{ elseif handle == "event_date" }} <input name="event_date" type="hidden" value="{{ event_date }}"> {{ else }} <label>{{ display }}</label> <div class="p-1">{{ field }}</div> {{ /if }} {{ /fields }} <button>Submit</button> {{ /form:contact }}
Bug description
Fields that have
visibility: hidden
don't show up in the form submission view. I'm expecting all fields to show and beread_only
in the form submission view, regardless of their visibility setting. Currently, fields are only visible when they have eithervisibility: visible
orvisibility: read_only
.How to reproduce
visibility: hidden
is not showing in the CPLogs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
runtime (new)
Additional details
This is also true for the
Hidden
fieldtype. I'm also expecting this field to be visible in the form submission.