input populate

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
sagarmitra's picture

Input values into drupal form programmatically

How can i populate the form fields programmatically
Let me illustrate, consider the following example

<?php

function form(){
return
drupal_get_form('myform');
}
function
myform($form_state){
   
$form['name'] = array(
  
'#type' => 'textfield',
'$title' => 'Name: ',
   );
$form['submit'] = array(
'#type' => 'submit',
   
'#value' => 'Save',
);
return
$form;
}
function
myform_submit($form,&$form_state){
   
$form_id = 'myform';
$form_state['values']['name'] = 'Hello World';
  
drupal_execute($form_id,$form_state);
}
?>
Read more
Subscribe with RSS Syndicate content