Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

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

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

Adding member cms fields for float data


Reply


5 Posts   2070 Views

Avatar
ryanwachtl

Community Member, 46 Posts

17 August 2008 at 6:28pm

Edited: 17/08/2008 6:29pm

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.

Avatar
Willr

Forum Moderator, 5513 Posts

18 August 2008 at 1:23pm

Edited: 18/08/2008 1:23pm

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

Avatar
ryanwachtl

Community Member, 46 Posts

18 August 2008 at 1:35pm

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.

Avatar
Willr

Forum Moderator, 5513 Posts

18 August 2008 at 1:52pm

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.

Avatar
ryanwachtl

Community Member, 46 Posts

18 August 2008 at 2:31pm

Edited: 18/08/2008 2:32pm

Great. Thanks for pointing out that oversight willr.

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

Uppercase F, and everything is playing nice now.