ProMotion-form icon indicating copy to clipboard operation
ProMotion-form copied to clipboard

Text fields sometimes convert content to a number

Open Siggs2000 opened this issue 11 years ago • 9 comments

Occasionally when I render the data from a form the text value entered is somehow changed to a huge negative number like: -1441151880758529039

It seems to happen most when the text value is very short. It also happens on password type forms.

I'm using gem version 0.3.1 and PM version 2.4.2 in redpotion 1.4.0

Siggs2000 avatar Oct 27 '15 21:10 Siggs2000

@Siggs2000 Can you show the code you are using to create the field and retrieve the value?

kevinvangelder avatar Oct 29 '15 18:10 kevinvangelder

@Siggs2000 We ran into this issue on the app we are working on as well. Related issue #47 for reference.

In redpotion you can find the form field and grab the text from it, but with more than a few form fields that can get messy.

The best solution we found was switching to PM-XLForm.

carlinisaacson avatar Oct 29 '15 19:10 carlinisaacson

I think I'm going to make that switch but ran into a little issue there that I just worked out this morning. Thanks.

Siggs2000 avatar Oct 29 '15 19:10 Siggs2000

Same problem here, drives me crazy... Here is the code:

class NewEntryTableScreen < PM::FormScreen
  title "Title"
  # stylesheet NewEntryTableScreenStylesheet

  def on_load
    set_nav_bar_button :right, title: "Save", action: :nav_right_button
  end

  def form_data
    [{
      title: "Date and time",
      cells: [{
        name: "time",
        title: "When?",
        type: :datetime,
      }, {
        name: "duration",
        title: "How long?",
        type: :text,
        placeholder: "Time in minutes"
      }, {
        name: "rating",
        title: "Rating?",
        type: :text,
        options: ["1", "2", "3", "4", "5"]
      }, {
        name: "description",
        title: "Description",
        type: :longtext
      }]
    }]
  end

  def nav_right_button
    mp render_form
  end
end

This is what gets rendered and I entered:

bildschirmfoto 2015-11-14 um 20 03 45

Terminal output:

(main)> {
  :time          => 2015-11-14 20:03:24 +0100,
  :duration      => -1441151880758558631,
  :rating        => "5",
  :description   => "my description"
}

mp data[:duration].class => Fixnum

andersennl avatar Nov 14 '15 19:11 andersennl

+1

Ligator avatar Nov 20 '15 01:11 Ligator

Hey guys,

I'm not going to be supporting ProMotion-form any longer. We now use ProMotion-XLForm instead. If you want to submit a patch for this, I'd be happy to merge it and release a new version, but won't have time to debug it myself.

Thanks!

jamonholmgren avatar Nov 20 '15 03:11 jamonholmgren

I switched to ProMotion-XLForm too and it was a really easy transition and it works great

Siggs2000 avatar Nov 20 '15 03:11 Siggs2000

Yeah I'll switch as well then, I just wasn't sure which gem to go with.

andersennl avatar Nov 20 '15 11:11 andersennl

ProMotion-form has been officially deprecated. Thanks everyone!

http://jamonholmgren.com/deprecating-promotion-form/

jamonholmgren avatar Nov 20 '15 18:11 jamonholmgren