virtual attribute on form

34 views
Skip to first unread message

Jorge Segura

unread,
May 14, 2013, 9:21:18 AM5/14/13
to net...@googlegroups.com
Hi, I just want to know the following: How can I access a virtual attribute defined in a model using a Netzke::Basepack::Form?

I am trying to access the values through overriding this endpoint "endpoint :netzke_submit do |params, this|" After clicked apply and get inside this endpoint I use js_record_data to access the value submited (is this the correct way to access it?, Should I access it through 'params' variable?) I want to do some logic with this virtual attribute.

I tried the following but it doesn't work:

#model
class User < ActiveRecord::Base
  attr_accesible *column_names

  #my virtual attribute
  attr_accessor :virtual_attribute
end

#netzke component
class UsuariosFormCrudUsuarioPassword < Netzke::Basepack::Form
   def configure(c)
      c.model = "User"
      c.record_id = session[:user_id]
      c.items = [
         {:id => :virtual_attribute, :name => :virtual_attribute, :xtype => :textfield, inputType:'password', :field_label => "Virtual Attribute", :read_only => false}
      ]
   end

   endpoint :netzke_submit do |params, this| 
      super(params, this)
      #debugger
   end
end

I hope you can help me.
Best regards.

ejo

unread,
May 21, 2013, 5:17:35 AM5/21/13
to net...@googlegroups.com
Just do this much

attr_accessor :virtual_attribute  #name of your virtual attribute
 c.items = [
         {name: :virtual_attribute, xtype: :textfield }
]


sreenivasulu

unread,
May 21, 2013, 6:09:52 AM5/21/13
to net...@googlegroups.com
Can u do like this.........

   #model
class User < ActiveRecord::Base
  
  #my virtual attribute
  attr_accessor :virtual_attribute
 netzke_attribute :virtual_attribute
end 

remaining same.........   
 

On Tuesday, May 14, 2013 6:51:18 PM UTC+5:30, Jorge Segura wrote:
Reply all
Reply to author
Forward
0 new messages