Input values into drupal form programmatically

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

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);
}
?>

Here, when submit event occurs, instead of getting the values populated, i get the white blank screen of death on the screen. Is something wrong with my syntax??

Comments

There is absolutely no reason

coderintherye's picture

There is absolutely no reason this should have been sent out to all these groups, if you have a support question it would be much better to post this in the forums on d.o. at http://drupal.org/forum

Drupal evangelist.
www.CoderintheRye.com

Good evening, Happy Holidays!

meeks53113's picture

Good evening,

Happy Holidays! I am trying to create a site similar, in structure, to this one: http://www.skelbiu.lt/. I know that views will be helpful in creating this type of website format. I'm trying to figure out, though, how to get links connected to each category. Any knowledge of how to do this? Thanks in advance!

Best,
Marcus

HI Marcus

rabithk's picture

You can use taxonomy for categorizing the content , then inside the view you can filter by node type , and get the count of for the corresponding category .

If you have still doubt plz contact me in bellow details, I am ready to help you .

E-mail: rabithk@gmail.com or Mobile: +91 8123553474


With Regards,
Rabith.k
E-mail: rabithk@gmail.com
Mobile: +91 8123553474

Regards,
Rabith Kuniyil.