Change Field Type from Int to Float - drupal

I'm helping a co-worker with a Drupal (6) issue, but I've never used Drupal before. The client wants to store decimal values in a field that was originally defined as an integer. I can't believe that this isn't possible without losing content or without doing a bunch of SQL copying, but I can't find anything that says, "sure, you can update the field type pretty easily, just do...".
Is this possible? So far:
We've altered the the content_type_thing table so that the _value field is now a float data type rather than an int.
We've updated the content_node_field table so the type value for that field is number_float
Now we can change the value from 1840 to 1840.25 without getting a validation error, but the .25 never gets saved. It gets chopped off and we get 18.00 in the database.
Any ideas?
Thanks.
UPDATE
Before anyone asks, I have read this post, but it looks like the recommendation involves a bunch of data migration. I just can't believe that there's not a way to change the data type in place.

This is pretty straight forward my friend. download this module
http://drupal.org/project/formatted_number
When you install it, go to the content type and change that field to use float.

Actually there is a solution but it's not easy and if you don't know exactly what
you're doing it may have side effects
https://drupal.stackexchange.com/questions/79378/changing-a-field-type-from-integer-to-decimal

Related

Can you pass pre-defined values to a formio text field from a static query string

I have a simple formio form set up with a basic text field component that I want to pass a value to based on a link a user will click to open the form.
I have tried passing a value with simple URL query string values.
My text field is named projectNumber. Tried passing values with something like this - https://url.com/formpage?projectNumber=project1 but it will not accept the value. I'm sure there is something simple I am missing. I have searched around quite a bit and gone through the formio documentation but have been unable to find anything related to what seems like a fairly simple scenario.
Has anyone else dealt with this situation and found a solution?

drupal move specific field to another field

I basically have a content type named "articles", and in this content type there is a reference field (that let me put unlimited data) called authorsref and a text field which as well let's me add as many as I want.
Both of this fields are called "authors".
What I want to do is move a specific reference field, to the text field, and then delete that reference field.
So for example, there are a hundred articles already, there are actually thousands and let's say 40 of them have a reference field with the author test1 amongst other reference fields and let's say as well that 60 of those hundred articles have as well a reference field of test2.
what I need to do is to somehow go over all the articles and where test1 and test2 reference fields are present, move them from the reference field authorsref to the text field authors.
I am as well a newbie and I have been trying to get this to work for the last three days and I just don't know how.
Please help, and thanks so much!
I think you need to use hook_update_n + batch.
hook_update_n - With this hook you can update some values in your DB.
Batch - you need to use batch for operations that may take a long time. (You don't want to time out PHP, you wont worry about it with batch).
Some examples here and here.

Change field length in drupal unit description

I'm having trouble using Drupal Rooms module.
This is when I input a description for unit.
Maximum length of Unit description is said to be 255.
I wanna input longer.
I figured out that those are stored in tables - field_data_unit_description_description and field_revision_unit_description_description.
I altered those tables, changed the length of the field to 2048.
But it still says "the text may not be longer than 255 characters."
I tried to change this value in db manually, but it never changed....
If i change the value in the site, the value in db changes, but if i change the value in db, it's not shown in the site.
Please help me.
I solved this problem myself by making a new attribute field for this.
It's quite better way I think since it works well and is fully customizable.
Created a new field in Manage Fields panel, with field attribute : Long Text.
It worked well.

Generate Number with Validating rule in Access

I have a database in access for institute. there is a [Registers] Table and [Certificates] Table.
I want to give Mark to each of Registers a Mark. I want to set Validation Rule for Each
If [Certificates].[Mark]>70
Then UpdateRecord
SetField
CertificateID "GENERATE AutoNumber"
My Problem is i cant handle the CertificateID Generate with Macro. i cant use DMAX.
looking for a solution to give CertificateID to only Registers who passed the Course.
Tried "After Update" Macro and "After Insert" macro but still didnt success.
is there any other way to give AutoNumber except "DMax"?
Well, i just already found a way but not the best way.
I just added another Table as "Certificates" and renamed current(Certificates) to "Marks".
Tables and Fields
i made a query with Select a "Grade" from Certificates Table and rest from Marks. Whenever i fill a record in Grade table it generate Autonumber for "CertificateID" a new number.
For Validation i set my validation Rule in my form on Grade which i cant fill that field if Marks.Mark is less than 70. ( [Marks].[Mark] < 70)
I know its not a good way.
Still looking for better answer

D6: how to get at node fields in preprocess_page()?

i created a view that displays my homepage fine but now a modification is needed: i load 2 fields (images) in my view but need to only display one of those, depending on the value of a third (date) field and today's date. if date field is later than today, show image y and if its earlier than today show image x. this kind of logic cant be done in a view.
so in my template.php id like to output x or y as $vars['img'] in the preprocess_page function. im just wondering, how do i get at the values of those fields? its not a node but a list of node teasers.
the function gets passed &$vars but a print_r of those just shows the html output.
custom sql seems not the way to go.
when i load the view, i just get the html it outputs but (i think) i need the raw data to make the date comparison.
thanks for any pointers!
I'm sure there are some ways to do this, some more hackier than others. I would:
Make a template specific to your view
Create a preprocess function for the view and create a boolean variable, by checking which img that should be displayed.
Lastly I would alter the template slightly by making an if statement that checks if it should display img x or y.
This solution is pretty easy and straight forward, the downside is that it's not completely general as you most likely will need to know the names of the cck field names you are using. It's doubtful you would be able to generalize this anyways.
Edit:
To clarify a bit. You can look at the general views template that's being used, it will give you some insight as to how views prints the different fields. Generally getting at the fields is usually not a big problem when you have the $node object. The reason is that cck adds the fields to the $node object so you can access it there. I believe you can do something in the line of $node->field_[the_name] to get to the field. I would suggest that you use the devel module if you don't already and do a dpm($node) somewhere in the template where you loop through the nodes. That will enable you to see what has been defined on the $node object. It shouldn't be a big problem to print the img from there.
How about using preprocess_node() instead?

Resources