Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Adding member cms fields for float data

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1951 Views
  • ryanwachtl
    Avatar
    Community Member
    46 Posts

    Adding member cms fields for float data Link to this post

    Hello all,

    I have added two float fields (storing latitude and longitude) to my member table. All works fine, but I am unable to save any data to the DB from the member popup cms in the admin. If I comment out the fields for the floats everything works.

    What is the proper way to add fields to the cms to except float data?

    I have tried these two with no success...

    $fields->push(new NumericField("lat", "Latitude"));
    $fields->push(new NumericField("lng", "Longitude"));

    $fields->push(new TextField("lat", "Latitude"));
    $fields->push(new TextField("lng", "Longitude"));

    Thanks.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Adding member cms fields for float data Link to this post

    what type of database fields are they saving into? try making them just 'Varchar' fields and see if it saves

  • ryanwachtl
    Avatar
    Community Member
    46 Posts

    Re: Adding member cms fields for float data Link to this post

    willr,

    The database fields were originally created as

    'lat' => 'float(10,6)',
    'lng' => 'float(10,6)'

    Which prevented any data from the Member cms popup from writing to the database.

    Using Varchar database fields works fine.

    'lat' => 'Varchar(30)',
    'lng' => 'Varchar(30)'

    Is there a reason why I was/am having trouble with the float fields? I tried setting them as 'null' and also as 'not null' with the same results, Member fields wouldn't update from the cms popup.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Adding member cms fields for float data Link to this post

    because float needs a capital F I guess as that db array does not use SQL eg float() type in MySQL but rather they should point to the wrapper in SilverStripe and for float its Float (uppercase F) try that and see how it goes.

  • ryanwachtl
    Avatar
    Community Member
    46 Posts

    Re: Adding member cms fields for float data Link to this post

    Great. Thanks for pointing out that oversight willr.

    'lat' => 'Float(10,6)',
    'lng' => 'Float(10,6)'

    Uppercase F, and everything is playing nice now.

    1951 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.