Kashia is proud to present you this little tip:

Dynamic Controls? Not really, or...?

This is how to make dynamic controls in Nitro 0.29 / 0.30 / 0.31 work!

This tip is deprecated in Nitro 0.40!

Dynamic because:

module Nitro
module Form

class MyTextControl < TextControl
  def render
    validation_error = "\#{(flash[:VERROR].respond_to?(:[]) && 
flash[:VERROR][:#{prop.symbol}]) ? 'invalid' : ''}"
    
    %{<input type="text" id="#{prop.symbol}_ctl" 
class="#{validation_error}" 
name="#{prop.symbol}" 
value="#{value}"#{emit_style}#{emit_disabled} />}
  end
end

end
end

See how the #{flash ...} is escaped?

This is how you insert your new control:

# ..

Form::Control.map.update(
  :string => Form::MyTextControl
)

# ..

If you take the easy way and just write:

<Page title="Yay!">
    #{form_for(@obj)}
</Page>

You'd just get the escaped stuff as text, speaking, nice "#{flash...}" in your html, pretty useless.

Now, this one does a better job: (But, as you can see, it is pretty fragile, don't use ~ nor | in your Control.)

<Page title="Yay!">
    <?r
    @out << eval(%|%~#{form_for(@obj)}~|)
    ?>
</Page>