Trying to figure out DRYML replace/merge capabilities

18 views
Skip to first unread message

j_McCaffrey

unread,
Nov 9, 2011, 6:39:27 PM11/9/11
to Hobo Users
I would like do remove the ability to edit the last_login_at from the
user form, as its not something you should edit. (I want to display
it, but just not edit it).

Is there a way to make this not editable in the form? (something at
the model level?)

There is an existing user form in forms.dryml
<def tag="form" for="User">
<form merge param="default">
<error-messages param/>
<field-list fields="first_name, last_name, company_name, title,
last_login_at, company_phone_number, email_address, role, state,
organization" param/>
<div param="actions">
<submit label="#{ht 'user.actions.save', :default=>['Save']}"
param/><or-cancel param="cancel"/>
</div>
</form>
</def>

In general I try not to completely override the defaults, I just merge
in my changes, so that if I add new columns, they will automatically
show up where they should.

I would like to do something like this in my application.dryml

<extend tag="form" for="User">
<old-form merge>
<field-list merge skip="last_login_at" />
</old-form>
</extend>

This kind of works, in that it hides the last_login_at (if I could
display it as non-editable that would be the best), but it also loses
the error-messages and submit buttons section.

How do I replace just parts of a defined tag, but not those elements
around it?
I feel like if I understand how to do this, it will go a long way in
helping me master Hobo. (I have wasted a lot of time screwing around
with dryml stuff so far)

Thanks for your help!

Bryan Larsen

unread,
Nov 10, 2011, 2:30:01 PM11/10/11
to hobo...@googlegroups.com
Adding a single colon will get you exactly what you want:

<extend tag="form" for="User">
<old-form merge>
<field-list: merge skip="last_login_at" />
</old-form>
</extend>

In the above you're modifying the 'field-list' param.

Without the colon, what you're doing is modifying the 'default' param
and instantiating a single instance of the 'field-list' tag inside the
form.

Bryan

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

kevinpfromnm

unread,
Nov 10, 2011, 2:52:03 PM11/10/11
to hobo...@googlegroups.com
You might also want to look at the permissions in addition (or alternatively) and add a restriction to last_login_at changing in the update_permitted? method.  See permissions manual for further info.
Reply all
Reply to author
Forward
0 new messages