You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.
class TestPage < Hyperloop::Component
def render
div do
form do
TestField(store: TestStore,
update_op: UpdateTestForm,
form_key: :test_form,
field_name: :test)
button(type: :submit)
end
end
end
end
class TestField < Hyperloop::Component
param :field_name, required: false
param :form_key, type: String, required: false
param :store, required: true
param :update_op, required: true
def update_value val
params.update_op.run(test_field: val.gsub(/\s/, ''))
end
def valid?
params.store.send(params.form_key)[field_error_name].present?
end
def field_error_name
"#{params.field_name}_error"
end
def render
div {
p { valid? ? "Valid" : "Invalid" }
input(type: :text).
on(:key_down, :key_up) { |e| update_value e.target.value }
}
end
end
class UpdateTestForm < Hyperloop::Operation
param :test_field, type: String, default: ''
param :test_field_error, type: String, default: ''
step { update_form }
def update_form
params.test_field_error = params.test_field.present? ? '' : "Can't be blank."
end
end
class TestStore < Hyperloop::Store
state test_form: {}, scope: :shared
receives UpdateTestForm do |params|
mutate.test_form(params)
end
def self.test_form
state.test_form
end
end
hyperloop-loader-system.self-ebeb435….js?bo…:20 Exception raised while rendering #<TestField:0xade>: undefined method `[]' for {"test_field"=>"", "test_field_error"=>"Test is invalid"}
Not sure what I'm doing incorrectly, as inspecting the TestStore.test_form outputs the correct hash, but it seems like it's a different class to Hash, and using hash methods on it does not work.
The text was updated successfully, but these errors were encountered:
Not sure what I'm doing incorrectly, as inspecting the TestStore.test_form outputs the correct hash, but it seems like it's a different class to Hash, and using hash methods on it does not work.
The text was updated successfully, but these errors were encountered: