By gopal123 on
I am trying to create simple textfield using drupal6 with below code
$form['foo'] = array(
'#type' => 'textfield',
'#title' => t('bar'),
'#default_value' => $object['foo'],
'#size' => 60,
'#maxlength' => 64,
'#description' => t('baz'),
);
by creating a page node with input format "php code", it creates well when I see preview it will not visible instead it displays nothing.
I am getting all text data but not php code written in( ).
Please give me if I need to change any settings etc...
Comments
All that you have done here
All that you have done here is create an array describing the form data. You need to convert this array into a form and then display it.Try adding (below the array but still inside php tags):
The should output a form, but you will still need a way of processing the form. This would normally be achieved in a custom module, or you might want to investigate the webform module.
simple textfield creation in drupal 6.x
when i use drupal_get_form() after the code I will be getting below message
warning: Illegal offset type in D:\wamp\www\drupal-6.4\includes\form.inc on line 352.
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in D:\wamp\www\drupal-6.4\includes\form.inc on line 366.
warning: Illegal offset type in isset or empty in D:\wamp\www\drupal-6.4\includes\form.inc on line 2258.
warning: Illegal offset type in D:\wamp\www\drupal-6.4\includes\form.inc on line 2262.
warning: Illegal offset type in isset or empty in D:\wamp\www\drupal-6.4\includes\form.inc on line 600.
warning: preg_match() expects parameter 2 to be string, array given in D:\wamp\www\drupal-6.4\includes\bootstrap.inc on line 723.
please let me know still i need to know any thing else...........
probably being caused by the
probably being caused by the $object['foo'] - try a string value here to see if it resolves the issue.Sorry, that function expects a form_id (the name of the function building the form). To process the form directly you would need to follow a process of preparing the form and rendering it - basically the steps taken by drupal_get_form. I think you will soon get to the point where you write the form in a module and then call it using drupal_get_form.