diff --git a/app/helpers/forms_helper.rb b/app/helpers/forms_helper.rb index a5d959d..a623c01 100644 --- a/app/helpers/forms_helper.rb +++ b/app/helpers/forms_helper.rb @@ -100,6 +100,13 @@ module FormsHelper content_tag('span', content, :class => 'required-field') end + def required_fields_message + content_tag('p', content_tag('span', + _("The fields are mandatory."), + :class => 'required-field' + )) + end + protected def self.next_id_number if defined? @@id_num diff --git a/app/views/account/_signup_form.rhtml b/app/views/account/_signup_form.rhtml index 456ef99..781eed2 100644 --- a/app/views/account/_signup_form.rhtml +++ b/app/views/account/_signup_form.rhtml @@ -1,8 +1,11 @@ <%= error_messages_for :user %> + <% labelled_form_for :user, @user, :html => { :help=>_('Fill all this fields to join in this environment.

If you forgot your password, do not create a new account, click on the "I forgot my password!" link. ;-)'), :id => 'profile-data' } do |f| -%> +<%= required_fields_message %> + <%= required f.text_field(:login, :onchange => 'this.value = convToValidLogin( this.value )') %> <%= help %> diff --git a/app/views/categories/_form.rhtml b/app/views/categories/_form.rhtml index e4110c8..90b5b4d 100644 --- a/app/views/categories/_form.rhtml +++ b/app/views/categories/_form.rhtml @@ -1,6 +1,9 @@ <%= error_messages_for 'category' %> <% labelled_form_for 'category', @category, :html => { :multipart => true} do |f| %> + + <%= required_fields_message %> + <% if @category.new_record? %> <% if @category.parent %> <%= hidden_field_tag('parent_id', @category.parent.id) %> diff --git a/app/views/cms/_event.rhtml b/app/views/cms/_event.rhtml index 26b3ae2..881ade3 100644 --- a/app/views/cms/_event.rhtml +++ b/app/views/cms/_event.rhtml @@ -1,3 +1,5 @@ +<%= required_fields_message %> + <%# TODO add Textile help here %> <%= render :file => 'shared/tiny_mce' %> diff --git a/app/views/cms/_folder.rhtml b/app/views/cms/_folder.rhtml index 82bc1d9..3f92896 100644 --- a/app/views/cms/_folder.rhtml +++ b/app/views/cms/_folder.rhtml @@ -1,3 +1,4 @@ +<%= required_fields_message %> <%# TODO add Textile help here %> <%= render :file => 'shared/tiny_mce' %> diff --git a/app/views/cms/_rss_feed.rhtml b/app/views/cms/_rss_feed.rhtml index bdb7331..24e3b4a 100644 --- a/app/views/cms/_rss_feed.rhtml +++ b/app/views/cms/_rss_feed.rhtml @@ -1,3 +1,5 @@ +<%= required_fields_message %> + <%= required f.text_field(:name) %> <%= required labelled_form_field(_('Limit of articles'), text_field(:article, :limit)) %> diff --git a/app/views/cms/_textile_article.rhtml b/app/views/cms/_textile_article.rhtml index 042595c..664b44d 100644 --- a/app/views/cms/_textile_article.rhtml +++ b/app/views/cms/_textile_article.rhtml @@ -1,3 +1,4 @@ +<%= required_fields_message %> <%# TODO add Textile help here %> diff --git a/app/views/cms/_tiny_mce_article.rhtml b/app/views/cms/_tiny_mce_article.rhtml index 0facfd7..53f043d 100644 --- a/app/views/cms/_tiny_mce_article.rhtml +++ b/app/views/cms/_tiny_mce_article.rhtml @@ -1,3 +1,4 @@ +<%= required_fields_message %> <%= render :file => 'shared/tiny_mce' %> diff --git a/app/views/cms/_uploaded_file.rhtml b/app/views/cms/_uploaded_file.rhtml index a6a009f..c3fd36d 100644 --- a/app/views/cms/_uploaded_file.rhtml +++ b/app/views/cms/_uploaded_file.rhtml @@ -1,3 +1,5 @@ +<%= required_fields_message %> + <%= required labelled_form_field(_("Select the file you want to upload (max size %s).") % UploadedFile.max_size.to_humanreadable, file_field(:article, :uploaded_data)) %> <%= labelled_form_field(_('Describe this file:'), text_area(:article, :abstract)) %> diff --git a/app/views/contact/new.rhtml b/app/views/contact/new.rhtml index 79dc4c9..8eff3e7 100644 --- a/app/views/contact/new.rhtml +++ b/app/views/contact/new.rhtml @@ -2,8 +2,11 @@ <%= error_messages_for 'contact' %> + <% labelled_form_for :contact, @contact do |f| %> + <%= required_fields_message %> + <%= f.text_field :name %> <%= f.text_field :email %> <%= labelled_form_field _('City and state'), select_city(true) %> diff --git a/app/views/content_viewer/_comment_form.rhtml b/app/views/content_viewer/_comment_form.rhtml index f7063cd..ff7f97e 100644 --- a/app/views/content_viewer/_comment_form.rhtml +++ b/app/views/content_viewer/_comment_form.rhtml @@ -19,6 +19,8 @@ <% form_tag( @page.url, { :id => comment_form_id } ) do %> + <%= required_fields_message %> + <% unless logged_in? %> <%= required labelled_form_field(_('Name'), text_field(:comment, :name)) %> diff --git a/app/views/manage_products/_form.rhtml b/app/views/manage_products/_form.rhtml index 0e00208..6754630 100644 --- a/app/views/manage_products/_form.rhtml +++ b/app/views/manage_products/_form.rhtml @@ -1,6 +1,8 @@ <%= error_messages_for :product %>
<% form_for :product, @product, :html => {:multipart => true }, :url => {:action => mode} do |f| %> + <%= required_fields_message %> + <%= required display_form_field( _('Name:'), f.text_field(:name) ) %> <%= display_form_field( _('Price:'), f.text_field(:price) ) %> <%= display_form_field( _('Description:'), f.text_area(:description, :rows => 10) ) %> diff --git a/app/views/memberships/new_community.rhtml b/app/views/memberships/new_community.rhtml index 75c488a..08ea548 100644 --- a/app/views/memberships/new_community.rhtml +++ b/app/views/memberships/new_community.rhtml @@ -6,6 +6,8 @@ <% labelled_form_for :community, @community do |f| %> + <%= required_fields_message %> + <%= required f.text_field(:name, :style => 'width: 100%') %> <%= f.text_area :description, :style => 'width: 100%; height: 150px;' %> diff --git a/app/views/role/_form.rhtml b/app/views/role/_form.rhtml index e0fc341..9db5aca 100644 --- a/app/views/role/_form.rhtml +++ b/app/views/role/_form.rhtml @@ -2,6 +2,8 @@ <% labelled_form_for :role, role, :url => (mode == :edit) ? {:action => 'update', :id => role} : {:action => 'create'} do |f| %> + <%= required_fields_message %> + <%= required f.text_field(:name) %> <%= _('Permissions:') %>
diff --git a/public/stylesheets/forms.css b/public/stylesheets/forms.css index 5bd3121..5770f5b 100644 --- a/public/stylesheets/forms.css +++ b/public/stylesheets/forms.css @@ -3,9 +3,12 @@ padding: 3px 0px; } +.pseudoformlabel, .formlabel { - /* font-size: 11px; */ color: #444; +} +.formlabel { + /* font-size: 11px; */ display: block; padding: 2px 5px; } diff --git a/test/unit/forms_helper_test.rb b/test/unit/forms_helper_test.rb index b973744..ee4c323 100644 --- a/test/unit/forms_helper_test.rb +++ b/test/unit/forms_helper_test.rb @@ -10,4 +10,20 @@ class FormsHelperTest < Test::Unit::TestCase assert_tag_in_string content, :tag => 'span', :attributes => {:class => 'required-field'} end + should 'wrapper required fields message in ' do + content = required_fields_message() + assert_tag_in_string content, :tag => 'span', :attributes => {:class => 'required-field'} + end + + should 'wrapper highlighted in label pseudoformlabel' do + content = required_fields_message() + assert_tag_in_string content, :tag => 'label', :content => 'highlighted', :attributes => {:class => 'pseudoformlabel'} + end + + protected + + def _(text) + text + end + end -- libgit2 0.21.2