Should be pretty straightforward but I am kinda stuck. I am prepopulating a mandatory field's value according to the URL, so I want to prevent the field from showing up, but not in a CSS level.
hide() and #access do not seem to submit the field leading to a validation error. Any clues on how would I go about doing this?
P.S. not a field of #type => hidden. An actual field. A select list if you want.
Comment trail clarifications:
1) the field is an entity field, a user field
2) the field is mandatory
3) the field is prepopulated using #value and #default_value (for safety (?))
4) the field should not be either visible or editable
5) I'd like to avoid adding a hidden and/or value field myself and write another submission/validation function since the user_register one works just fine. I want to use the value that the field has upon the form's rendering taking into consideration point 4.
#type => value
on the backend, so it never has to be displayed on the form itself#type => value
in your form definition/form alter. That way it will be available server side, can be pre-populated in your form logic, and won't show to the user. Or if you're not bothered about doing it 'properly' just add#disabled => TRUE
to the element and hide it with CSS