Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Inputs Fields #6875

Open
MichaelHarmsTIB opened this issue May 25, 2022 · 4 comments
Open

Form Inputs Fields #6875

MichaelHarmsTIB opened this issue May 25, 2022 · 4 comments
Assignees

Comments

@MichaelHarmsTIB
Copy link

CKAN version
2.9.3
Describe the bug
I follow this documentation:
https://docs.ckan.org/en/2.9/contributing/frontend/templating.html#form-macros
My code:
{% import "macros/form.html" as form %}
{{ form.input("email", id="field-email", label=("Email"), type="email", placeholder=("joe@example.com"), value=data.email, error=errors.email, classes=["control-medium"], is_required=True) }}
{{ form.checkbox('agree_license', label=_(" Ich akzeptiere die Nutzungsbedingungen des Forschungsdatenrepositoriums des FID move."), id='field-agree_license', checked=false, is_required=True) }}

The E-Mail input field is a original code raw from new_user_form.html and is_required doesn't work nor my own field {{ form.checkbox ..

Expected behavior
If is_required=true and checkbox or input field is empty, the form doesn't submit.

So what is exactly to do?

Additional details
Please could someone write for the documentation more examples.

@TomeCirun
Copy link
Contributor

@MichaelHarmsTIB ckan/logic/scheme.py module is incharge of which field is going to be required and which not, we are validating our forms in our actions (ckan/logic/action package) and this is one example of it:

data, errors = lib_plugins.plugin_validate(
we are sending the data (which we are previously getting in some of our views via request.form) alongside our scheme for validation.

I think that is_required is only for decoration, it will mark the field with * so you as a user will know that this field must not be empty:)

Thanks

ps correct me if I've missed something @amercader @tino097

@MichaelHarmsTIB
Copy link
Author

There is no table user_extra, so I have a problem so extend a form in the way I did it for a dataset.
How can I extend a form for register (new_user.html) ?

@wardi
Copy link
Contributor

wardi commented Jun 2, 2022

We don't have an easy way to extend the user form yet #6070, but some of the underlying work was done by @amercader to support storing values and can be used to extend the form with a bit of extra effort #5382

@Mohab25
Copy link

Mohab25 commented Sep 5, 2022

@TomeCirun maybe not the same issue but slightly relevant, having a custom scheming Select field that have "others" as an option, once selected it shows a text input that takes data from user, once there is a submit, if you logged the data it shows the custom field value, but if logged the result of package_create action or package_update action from the same data the custom field value isn't their, however it's stored in the database as {"__extras":"field_name":"field_value"}, but when retrieving it won't show it up , i've noticed if the context is logged for package create and update, it shows "plugin_extras=None", please refer to these shots for more reference:
don't want to confuse with the actual markup of the custom field, here is how it looks:

custom-scheming-field

if i tried to log the submitted data, i can still see the field is there:

custom field appears in the submitted data

this is the field value showing in the database:

data is persistent in the database

but the result of package_create of package_update actions won'e show the custom field data:

action result won't show data

thank you for any help, i've actually had a similar question of stackoverflow but no one responded, saw this as oportunity for a similar issue,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants