On Thu, Mar 8, 2012 at 4:05 PM, Bob Sleys <[email protected]> wrote:
> I need to init a field in that is filled out via an input-many tag.  The
> thing is I can't init it in the model because the init value comes from a
> session variable.  I tired using a new_for_model method in the models
> controller but that doesn't seem to be being called.  I also though about
> doing it in the dryml but then I ended up over riding the records value in
> already existing records.

input-many has a 'template' attribute that can be used:

<input-many template="&Foo.new(:bar => 17)"/>

>
> Any ideas?
>
> On a related note I have another field in the same <input-many> tag that I
> wanted to use :creator => true on the relationsahip. But when I include the
> field in the form it isn't defaulting to the current user.
>
> Here is the relationship as defined in the model
>
>   belongs_to :field_tech, :class_name => "User", :creator => true,
> :conditions => "employee = 't'"
>

As far as I'm aware, that little piece of magic only happens for
generated forms, so you'll have to take care of it yourself here.
Here's one way to do it:

<input-many>
  <hidden-field:field-tech-id value="&current_user.id"/>
  <field-list fields="..."/>
</input-many>

if you don't have hidden-field:
<def tag="hidden-field">
  <%= hidden_field_tag(param_name_for_this, this, attributes) %>
</def>

Bryan

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to