# How to get value of Textarea in node add form?

In my node add form I have added one text area :

function mymodule_form_alter(&$form,$form_state, $form_id) { if ($form_id == "contenttype_node_form") {
if (!isset($node->nid) || isset($node->is_new)) {
$form['extra']['#title'] = t('Title (Extra)');$form['extra']['#type'] = 'textarea';
$form['extra']['#required'] = TRUE;$form['extra']['#cols'] = '15';
$form['extra']['#resizable'] = FALSE;$form['extra']['#rows'] = '5';

$form['#submit'][] = 'my_trans_submit'; } } } function my_trans_submit(&$form, &$form_state){$swed_title = $form['extra']['#value']; }  Above code display one textarea just after title field in my node form. I Need the value entered in this text-area when user click on save node and then I want to use that value and save translation by running node save function. I can get this on form submit, but at that time node is not created and nid is not available. How can I get value entered by the users in the above textarea once the node is saved and the node ID will be available, allowing me to use node_save()? Do I have to use a form field? I was not using a form field as it creates a new entity table. • save translation means? what exactly this field using for? – vgoradiya Mar 18 '16 at 12:45 • I need to run this code drupal.stackexchange.com/questions/123460/… by using value entered in textarea. By doing this user will save node and its translation at same time ie: in one node save click by user from from. – jas Mar 18 '16 at 12:47 • In my case I want to use that value $node->field_title['fr'][0]['value'] = $from['extra']['value']; but all other things are also required like nid etc so just need that value after node get saved. – jas Mar 18 '16 at 12:52 • I think I need to use hook_node_insert – jas Mar 18 '16 at 12:59 • As side note, a form submission handler gets the values the user entered from $form_state['values'], not from $form. – espero Mar 18 '16 at 23:45 ## 1 Answer Shortly put, you need to do the following: • Use hook_form_alter, the way you do already • Use hook_node_submit, to update the field_title field on the node object, before it gets saved. In your hook implementation you will have access to both$form and $form_state, which should carry your custom textarea submitted value. Even if the nid is not there, your changes should still get stored in the new node. Hope this helps! • thanks but I need to add$node->translations->data in entity_translation table as well. By default this enter data related to default language when node gets created. So in hook_presave is that will be possible to add like drupal.stackexchange.com/questions/123460/…. Just asking for more clarification, please suggest ? – jas Mar 18 '16 at 13:04
• I updated my answer, I find that hook_node_submit is even better than hook_node_presave, see above. And yes, that code from the link you provide should make it possible to add translations to your entity (node). – Stefanos Petrakis Mar 18 '16 at 13:12
• Grand, happy to hear! – Stefanos Petrakis Mar 18 '16 at 21:53