I'm using Drupal 7 and I have made a custom module in which there is this function.
function product_search_by_pin_form($form, &$form_state) {
// Provide a text field.
$form['pin'] = array(
'#method'=> 'POST',
'#action' => '$come_back',
'#title' => t('Input your PIN'),
'#type' => 'textfield',
'#attributes' => array('size' => '20', 'maxlength' => '20'),
'#placeholder' => 'Type your PIN',
'#required' => TRUE,);
// Provide a submit button.
$form['submit'] = array(
'#type' => 'image_button',
'#required' => TRUE,
'#src' => "/images/upload/search.png",
'#attributes' => array('id' => 'submit'),
'#value' => 'Search',);
return $form;
} // END of Function
The form is being used from the following code.
$arr = drupal_get_form('product_search_by_pin_form');
print drupal_render($arr);
The problem is that Drupal displays the Array instead of showing the form.
How can I solve it?
EDIT As asked, and after have followed suggestions but without result, please here the code of the module
<?php
/**
* @file
* a test file
*/
/**
* Implements hook_menu().
*/
function myform_menu() {
$items = array();
$items['/examples/myform-examples'] = array(
'title' => 'Example myform',
'description' => 'Configuration for TEST module',
'page callback' => 'drupal_get_form',
'page arguments' => array('product_search_by_pin_form'),
'access callback' => TRUE
);
return $items;
}
/**
* Implements hook_help().
*
* Displays help and module information.
*
* @param path
* Which path of the site we're using to display help
* @param arg
* Array that holds the current path as returned from arg() function
*/
function myform_help($path, $arg) {
switch ($path) {
case "admin/help#myform":
return '' . t("<b>Myform</b> to test a drupal form") . '';
break;
}
}
function product_search_by_pin_form($form, &$form_state) {
// Provide a text field.
$form['pin'] = array(
'#method'=> 'POST',
'#action' => '$come_back',
'#title' => t('Input your PIN'),
'#type' => 'textfield',
'#attributes' => array('size' => '20', 'maxlength' => '20'),
'#placeholder' => 'Type your PIN',
'#required' => TRUE,);
// Provide a submit button.
$form['submit'] = array(
'#type' => 'image_button',
'#required' => TRUE,
'#src' => "/images/upload/search.png",
'#attributes' => array('id' => 'submit'),
'#value' => 'Search',);
return drupal_get_form($form);
} // END of Function
.module
file?.module
fileaction
ormethod
properties. Those are for the form only. Submit buttons can't be required either