anjlab / anjlab-widgets

UI Widgets on top of anjlab-bootstrap-rails
MIT License
54 stars 15 forks source link

Multiparameter Assignment Error #7

Closed DevanB closed 11 years ago

DevanB commented 11 years ago

I get that dreaded Multiparameter error when I try to edit a record that has been created with the timepicker and datepicker. Any idea how to avoid this? I'm writing the time and date to the database as a string not datetime format, if that helps.

ActiveRecord::MultiparameterAssignmentErrors in EventsStepsController#create 1 error(s) on assignment of multiparameter attributes

yury commented 11 years ago

I need a little bit help on your side.

  1. Are you using simple_form?
  2. Can you show view part for date/time?
yury commented 11 years ago

date/time elements generates on(2i), on(1i) and so on by default. You should pass rails: false in input_html options to disable that

DevanB commented 11 years ago

Sure!

I'm using simple_form and setup the initializer like so: Anjlab::Widgets.simple_form

here are my two fields. The fields in the db are a :string (varchar) not a :datetime.

<%= f.input :time, as: :anjlab_time, label: 'Event Start Time:' %>
<%= f.input :date, as: anjlab_date, label: 'Event Start Date:' %>

On Aug 5, 2013, at 11:03 AM, Yury Korolev notifications@github.com wrote:

I need a little bit help on your side.

Are you using simple_form? Can you show view part for date/time? — Reply to this email directly or view it on GitHub.

DevanB commented 11 years ago

If I understand it correctly the fields should be as such:

<%= f.input :time, as: :anjlab_time, label: 'Event Start Time:', :input_html => {rails: false} %>
<%= f.input :date, as: :anjlab_date, label: 'Event Start Date:', :input_html => {rails: false} %>
yury commented 11 years ago

I was wrong…

For you, it is better to use plain strings

<%= f.input :time, as: :string, label: 'Event Start Time:', input_html: {data: {widget: 'timepicker'}, type: 'time'} %>
<%= f.input :date, as: :string, label: 'Event Start Date:', input_html: {data: {widget: 'datepicker'}, type: 'date'} %>
DevanB commented 11 years ago

I can see it is putting rails: false in, but I still get the error.

input class="anjlab_time optional" data-rails="true" data-widget="timepicker" id="event_time" name="event[time]" rails="false" size="30" type="text" value="" data-validate="true"

DevanB commented 11 years ago

Well that is working for the time selection, but not the date. When using the date selection I can see the MM/DD/YYYY placeholder, but when I select a date from the drop down calendar, it doesn't actually update the placeholder with the new input.

yury commented 11 years ago

that with as: :string?

DevanB commented 11 years ago

Yep, as this:

<%= f.input :date, as: :string, label: 'Event Start Date:', input_html: {data: {widget: 'datepicker'}, type: 'date'} %>
yury commented 11 years ago

Do you lang attribute in your html tag?

DevanB commented 11 years ago

I'm not quite sure what you mean. I'm new to Rails, just building something to teach myself.

I'm assuming you mean does my tag look like this at the top of application.html.erb:

html lang="en"

Is that right?

yury commented 11 years ago

Yep, in html document it should be like

<html lang='en'>….

Trying to reproduce…. without luck...

DevanB commented 11 years ago

Don't know if they will help any, but it's a quick screencast of the problem.

http://cl.ly/213y0S3N2Z1Y

On Aug 5, 2013, at 1:28 PM, Yury Korolev notifications@github.com wrote:

Yep, in html document it should be like

…. Trying to reproduce…. without luck... — Reply to this email directly or view it on GitHub.
yury commented 11 years ago

Yep, video does help a lot.

for now please use type text for your date/time inputs

<%= f.input :date, as: :string, label: 'Event Start Date:', input_html: {data: {widget: 'datepicker'}, type: 'text'} %>

DevanB commented 11 years ago

Thanks for the help! I haven't been able to get a time picker or date picker working (and I tried the bootstrap-rails-timepicker/datepicker gem) for over a month now!

I'm not quite sure what is happening in the data-widget stuff, but thanks! Hopefully I helped you some also with the gem ;)

yury commented 11 years ago

Wait a moment….

Are you still using anjlab-widgets pickers and they work or you switched to bootstrap-rails-timepicker?

Sorry my bad english :(

DevanB commented 11 years ago

Your English is just fine :)

I am still using anjlab-widgets. The bootstrap-rails-timepicker would not work, so I switched to anjlabs :)