On Martes, 30 de Agosto de 2011 16:48:07 Liehann escribió:
> Hi,
>
> I'm making an override for a form column that essentially renders a
> checkbox list (which is then converted into a multi select lists). The
> problem is that I need both the record and the column to do this.
>
> In FormColumnHelpers the override_form_field method is passed @record,
> and the override_input method is passed the column, but neither is
> passed both.
override_form_field doesn't need column, you know the column name and you can
get with active_scaffold_config.columns[name]. It could be passed so you cannot
need to get it from config, but current apps will break.
override_input (form_ui methods) get the column. They should get record,
because is not good to use @record, many active_scaffold methods should get the
record instead of lying in getting the record through @record variable.
However they don't get @record because first form_ui methods used methods like
select, textarea and so on, which lied in @record by default. It should be
changed, and it shouldn't break many apps, most apps won't add form_ui
methods, but maybe there are some plugins which need to be updated.
>
> I ended up patching my branch of ActiveScaffold to pass both to the
> override_form_field method, but I'm falling behind the official
> releases, to this isn't going to work going forward. Any suggestions?
>
> My helper function looks like this:
> def lines_form_column(column, record, options)
> # Select all lines associated with the order, or associated with
> no order.
> lines = Line.all(:order => ['msisdn asc'], :conditions =>
> ['(order_id is null or order_id = ?)', record.id ])
> associated_lines = lines.select{|l| l.order_id}.map{|l| l.id}
> lines.map!{|l| [l.to_label, l.id]}
>
> # Render the checkbox list then convert the checkboxes to multi
> select lists.
> active_scaffold_checkbox_list(column, lines, associated_lines,
> options) +
> javascript_tag("new MultiSelectLists('#{options[:id]}')")
> end
You can add this line:
colum = active_scaffold_config.columns[:lines]
and then it will work with ActiveScaffold without your changes.
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.