drupal - Programmatically get and set field values -
I have two fields that I want to fill with exactly the same values; Users should fill only one.
I also have a function that checks whether the second field is empty or not. How are the field values obtained in dripple 6 and drupal 7 and set?
EDIT: I'm just trying to edit the module. Yes, I'm talking about the node field. The $ node array has the ID of the words added only in the node. How can I know my name?
Since you have tagged this question with cck. I think that with the node field Are working.
To copy the value of one field ( x ) to another ( y ), you can either install the module and set it up So that the value of y is calculated by the value of x , or you can create a custom module with something similar to the following: This hook copies all data in the field x from x : This hook simply copies the value of the first instance of the x field y field: You can replace
function mymodule_node_presave ($ node) {$ node -> field_y = $ node- & gt; Field_x; }
function mymodule_node_presave ($ node) {$ node-> Field_y [$ node- & gt; Language] [0] ['value'] = $ node-> Field_x [$ node- & gt; Language] [0] ['value']; }
print_r at
$ node-> field_x and
$ node- & gt; Field_y want to do as the structure of your data may vary, the type of field you are using. If you want to see that any of the fields is empty, you can wrap the assignment statement conditionally, which calls your custom function.
Comments
Post a Comment