Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6652667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:10:09+00:00 2026-05-26T01:10:09+00:00

I know it might be a silly question to ask, but I have a

  • 0

I know it might be a silly question to ask, but I have a field say a and b, now how to get the value and set the value for a and b.
Right now my code is like this..

$n = node_load($node->id);
$n->title;

I am getting the node title, I want to know how to get and set the value for a and b please, and if i set the value of a and b will itt be saved using

node_save($n);

??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:10:10+00:00Added an answer on May 26, 2026 at 1:10 am

    It depends a bit which version you’re using and on the particular field types you’re using, but something like this:

    // Drupal 6
    $n = node_load($node->id);
    $n->title = 'A title';
    $n->field_my_field_a[0]['value'] = 'A value';
    $n->field_my_field_b[0]['value'] = 'B value';
    node_save($n);
    
    // Drupal 7
    $n = node_load($node->id);
    $n->title = 'A title';
    $n->field_my_field_a[LANGUAGE_NONE][0]['value'] = 'A value';
    $n->field_my_field_b[LANGUAGE_NONE][0]['value'] = 'B value';
    node_save($n);
    

    In both cases the field data will be saved along with the node when you call node_save().

    It’s worth noting that the 0 index in both cases refers to the first item in a field. If a field has multiple values you can just keep adding to the array. The value key might need to change depending on the type of data that the field holds (for example a filefield will hold the fid (file id) of the file it holds so adjust accordingly.

    Also LANGUAGE_NONE might need to be replaced by the required language code if you’re using the Drupal 7 version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this might sound a silly question, but I did not find in
This may be a silly question but... Say you have a sentence like: The
I know this might sound silly but I have no idea how to do
I have a question with security point of view, it might sound silly but
This is might seem to be a sort of silly question to ask but
This might come across as a silly question but I am curious to know
This might be a silly a question. But I am just curious to know
This might seems silly question but for me it is annoying. I have installed
This question might be silly, but I want to know, if a copy constructor
That might be silly question but I really need to know the answer. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.