Fixe, fixed and refactored.

Since I did not find any effective way how to disable field, I am still
using HTML disable feature, but when the form is submitted, I re-enable
all allocation fields so they are submitted. Nice catch btw!

LZ

On Mon, Dec 09, 2013 at 05:25:56AM -0800, Dominic Cleal wrote:
> > @@ -1,6 +1,21 @@
> >  <div class="fields">
> >    <%= selectable_f f, :pool_name, compute_resource.storage_pools.map(&:name), { }, :class => "span2", :label => _("Storage Pool") %>
> > -  <%= text_f f, :capacity, :class => "input-mini", :label => _("Size (GB)") %>
> > -  <%= select_f f, :format_type, %w[RAW QCOW2],:downcase, :to_s, { }, :class => "span2", :label => _("Type"),
> > +  <%= text_f f, :capacity, :class => "input-mini", :label => _("Size (GB)"), :onchange => 'capacity_edit(this)' %>
> > +  <%
> > +    active = 'Size'
> > +    active = 'None' if f.object.allocation.starts_with? '0'
> > +    active = 'Full' if f.object.allocation == f.object.capacity
> 
> The whole block including the text_f could be lifted into a helper, it might be a little clearer then, but I probably wouldn't move just the active logic.
> 
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/theforeman/foreman/pull/1073/files#r8196357

-- 
Later,

 Lukas "lzap" Zapletal
 irc: lzap #theforeman