Skip to content

Commit

Permalink
Fixed 'param' option on [select] method.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Jan 17, 2011
1 parent 647c1c8 commit e5dca21
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions lib/zena/use/display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ def extract_label(res, params, attribute)
"<label><%= #{code} %></label> <span>#{res}</span>"
end
end
else
res
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/zena/use/forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def r_select
end

html_id = html_attributes[:id] ? " id='#{html_attributes[:id]}'" : ''
if @context[:in_filter]
if @context[:in_filter] || @params[:param]
select_tag = "<select#{html_id} name='#{attribute}'>"
else
select_tag = "<select#{html_id} name='#{node.form_name}[#{attribute}]'>"
Expand Down Expand Up @@ -467,7 +467,7 @@ def r_input
wrap('')
else
# 'text', 'hidden', ...
return parser_error('Missing name.') unless attribute
return parser_error('Missing name.') unless attribute || html_attributes[:name]
@markup.tag = 'input'
@markup.set_param(:type, @params[:type] || 'text')

Expand All @@ -478,7 +478,7 @@ def r_input
wrap('')
end

extract_label(res, @params, attribute)
extract_label(res, @params, attribute || html_attributes[:name])
end

# <r:checkbox role='collaborator_for' values='projects' in='site'/>"
Expand Down
4 changes: 2 additions & 2 deletions test/integration/zafu_compiler/errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ query_on_vclass:
# typical syntax error (should be Contact?)
src: "<r:Contact><div do='pages in site'>...</div></r:Contact>"
# should not crash
tem: "<% if var1 = VirtualClass[\"Contact\"] -%><span class='parser_error'><span class='method'>pages in site</span> <span class='message'>No query builder for class VirtualClass</span></span><% end -%>"
tem: "/parser_error.*method.*pages in site.*No query builder for class VirtualClass/"

datebox_on_vclass:
src: "<r:Contact><r:input type='date' name='log_at'/></r:Contact>"
tem: "/unknown method 'log_at\(\)' for VirtualClass./"
tem: "/unknown method 'log_at\(\)' for .* VirtualClass./"
6 changes: 5 additions & 1 deletion test/integration/zafu_compiler/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,8 @@ label_on_select:
context:
lang: fr
src: "<r:select label='t' name='title' values='1,2'/>"
res: "/<label>titre</label> <span><select name='node\[title\]'/"
res: "/<label>titre</label> <span><select name='node\[title\]'/"

param_on_select:
src: "<r:select param='q[contact.status]' values='0,-5,-10' tshow='active, being registered, inactive'/>"
res: "<select name='q[contact.status]'><option value=\"0\">active</option>\n<option value=\"-5\">being registered</option>\n<option value=\"-10\">inactive</option></select>"
2 changes: 1 addition & 1 deletion zena.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Gaspard Bucher"]
s.date = %q{2011-01-16}
s.date = %q{2011-01-17}
s.default_executable = %q{zena}
s.description = %q{zena is a Ruby on Rails CMS (content managment system) with a focus on usability, ease of customization and web 2.0 goodness (application like behaviour).}
s.email = %q{gaspard@teti.ch}
Expand Down

0 comments on commit e5dca21

Please sign in to comment.