:(
Does not work...
Maybe is because I have a new_for action
def new_for_fraccao
hobo_new_for :fraccao do
if params[:fraccao_id]
@fraccao=Fraccao.find(:first, :conditions=> ["id
= ?",params[:fraccao_id] ])
original = Morada.find(:first, :conditions=> ["imovel_id
= ?",@fraccao.imovel_id])
this = @morada= original.clone
else
@morada.attributes = params[:morada] || {}
hobo_ajax_response if request.xhr?
end
end
end
and even a
def create_for_fraccao
@cont= Morada.new(params[:morada])
if @cont.save
flash[:notice] = "Morada adicionada com sucesso"
respond_to do |format|
format.html { redirect_to fraccao_path(@cont.fraccao.id) }
format.js
end
else
hobo_create do
this.attributes = params[:morada] || {}
hobo_ajax_response if request.xhr?
end
end
end
I do not understand why, but maybe the create for is smashing the
parameters from new for?
Thanks
On 26 Mar, 03:59, kevinpfromnm <[email protected]> wrote:
> basically, hobo_new creates a new model and passes it off to view
> unless it's a redirect from failed validation in which case, it pulls
> in the info from the parameters. you could pass an id as a parameter
> and add a check for it
> def new
> if param[:id]
> original = ModelClass.find_by_id param[:id]
> this = @modelclass = original.clone
> else
> your original code
> end
> end
>
> I'm sure there's a cleaner way to do it but that should work.
>
> On Mar 25, 6:17 pm, Daniel M <[email protected]> wrote:
>
>
>
> > Hi all.
>
> > I have one controller with ajax request like its described on the
> > recipe -http://cookbook.hobocentral.net/recipes/15-dynamically-
> > populated-select-menus
>
> > def new
> > hobo_new do
> > this.attributes = params[:project] || {}
> > hobo_ajax_response if request.xhr?
> > end
> > end
>
> > It´s working ok, but now I will need do send pre-filled data to new
> > form from other record. For example how i can create a new page with
> > the project name already filled?
>
> > The ideia is to find another project and fill the new form with
> > exactly the same data except the city..for example.
>
> > Thanks in advance.
>
> > Regards.
--
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.