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

Add HTML5 'required' attribute to form widgets. #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add HTML5 'required' attribute to form widgets. #28

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 13, 2018

Hello @artyom-beilis,

In current version, CppCMS does support 'disabled' attribute on form widgets. But, if a developer would like to add 'required' attribute to form widgets in templates, he/she is required to write that part manually each time.

This commit provides code for 'required' attribute.

  1. Changes in the commit are following 'disabled' attribute's implementation.
  2. non_empty() function automatically calls required(true).
  3. Call to at_least with positive number automatically sets required attribute.
  4. Call to limits with positive min argument automatically sets required attribute.

To not break backward compatibility, required flag is not checked if the widget have non_empty(). But this may cause confusion for new developers, so what's your opinion? Should CppCMS check even if non_empty() function is present?

Thanks.

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

Successfully merging this pull request may close these issues.

0 participants