hook elements problem
Hello, I like to make some own form elements: function atleta_elements() { $type['meter'] = array('#input' => TRUE, '#size' => 60); return $type; } but when I like to use it: $form['meter2'] = array( '#title' => 'meter2', '#type' => 'meter', ); I do not see this element. What is the solution? Ámon Tamás Sitefejlesztő és programozó -- 5NET Informatikai Kft. 1062 Budapest, Aradi utca 38. A 3/11 telefon: (1) 461-0205 | fax: (1) 461-0206 e-mail: amont@5net.hu | web: http://www.5net.hu
Hi, You need a rendering function or template file. Konstantin On 08.09.2008, at 09:50, Ámon Tamás wrote:
Hello,
I like to make some own form elements:
function atleta_elements() { $type['meter'] = array('#input' => TRUE, '#size' => 60); return $type; }
but when I like to use it:
$form['meter2'] = array( '#title' => 'meter2', '#type' => 'meter', );
I do not see this element. What is the solution?
Ámon Tamás Sitefejlesztő és programozó -- 5NET Informatikai Kft. 1062 Budapest, Aradi utca 38. A 3/11 telefon: (1) 461-0205 | fax: (1) 461-0206 e-mail: amont@5net.hu | web: http://www.5net.hu
As Konstantin said, but in more understandable terms: You need a theme function for your element - how does Drupal know what your element is supposed to look like? You can register it with hook_theme - see http://api.drupal.org/api/function/hook_theme/6. Then, your theme function accepts one argument, $element. You can return HTML. See http://api.drupal.org/api/function/theme_fieldset/6 for an example. Dmitri 2008/9/8 Konstantin Käfer <kkaefer@gmail.com>:
Hi,
You need a rendering function or template file.
Konstantin
On 08.09.2008, at 09:50, Ámon Tamás wrote:
Hello,
I like to make some own form elements:
function atleta_elements() { $type['meter'] = array('#input' => TRUE, '#size' => 60); return $type; }
but when I like to use it:
$form['meter2'] = array( '#title' => 'meter2', '#type' => 'meter', );
I do not see this element. What is the solution?
Ámon Tamás Sitefejlesztő és programozó -- 5NET Informatikai Kft. 1062 Budapest, Aradi utca 38. A 3/11 telefon: (1) 461-0205 | fax: (1) 461-0206 e-mail: amont@5net.hu | web: http://www.5net.hu
Or, you could take a look at the example_element module: http://api.drupal.org/api/file/developer/examples/example_element.module/6 2008/9/8 Dmitri G <dmitrig01@gmail.com>:
As Konstantin said, but in more understandable terms:
You need a theme function for your element - how does Drupal know what your element is supposed to look like?
You can register it with hook_theme - see http://api.drupal.org/api/function/hook_theme/6.
Then, your theme function accepts one argument, $element. You can return HTML. See http://api.drupal.org/api/function/theme_fieldset/6 for an example.
Dmitri
2008/9/8 Konstantin Käfer <kkaefer@gmail.com>:
Hi,
You need a rendering function or template file.
Konstantin
On 08.09.2008, at 09:50, Ámon Tamás wrote:
Hello,
I like to make some own form elements:
function atleta_elements() { $type['meter'] = array('#input' => TRUE, '#size' => 60); return $type; }
but when I like to use it:
$form['meter2'] = array( '#title' => 'meter2', '#type' => 'meter', );
I do not see this element. What is the solution?
Ámon Tamás Sitefejlesztő és programozó -- 5NET Informatikai Kft. 1062 Budapest, Aradi utca 38. A 3/11 telefon: (1) 461-0205 | fax: (1) 461-0206 e-mail: amont@5net.hu | web: http://www.5net.hu
participants (4)
-
andrew morton -
Dmitri G -
Konstantin Käfer -
Ámon Tamás