Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is the error I'm getting:
warning: implode() [function.implode]: Bad arguments. in C:\xampp\htdocs\drupal5\web\includes\form.inc on line 622.
And this is the code I'm trying:
<?php
$form['test'] = array(
'#type' => 'select',
'#title' => t('Discard logs older than'),
'#default_value' => variable_get('timer', 259200),
'#options' => array('one', 'two'),
'#description' => t('The timer.'),
);
echo drupal_render($form);
The idea being that I would use a db query to pull select values. This is just dummy data I was trying out to see if this idea would work.
Comments
Comment #1
quicksketchdrupal_render() will only work on completely processed form elements, after they've run through form_builder() (such as in the theme layer). The implode error is because the #parents() field isn't yet populated I believe.
Anyway, this approach wouldn't work either way, because the FormsAPI needs to know what new elements you're rendering. Drupal's form security would prevent an element like this from being processed because it'd be equivalent to creating new form elements on the page with Firebug (or similar). The better approach here would be to simply make the select element take PHP code as an option. I haven't gotten into it because it'll get into permissions for who can use the PHP code, and what to do when a user that can't use PHP code edits the select list.
If interested in contributing/following, the issue is at: http://drupal.org/node/151603
Comment #2
quicksketchClosing after lack of response.