By dproger on
Hi
I am trying to create a form. One of fields should contains name like "info.field.label". Drupal can't post the variable for that field after I press the submit button.
[info.field.label] => Array
(
[#type] => textfield
[#title] => Field label info
[#required] => FALSE
[#default_value] => test value
)
Is it bug?
Comments
That's not a bug, it's how
That's not a bug, it's how PHP is designed. The dot is not allowed in variable names, see http://www.php.net/manual/en/language.variables.basics.php. You can use underscores:
info_field_label. If you still need "info.field.label" as a string, add it as a value to your array, or do astr_replace('_', '.', $name)on the name when you need it.How drupal works at
How drupal works at all?
in normal php work above statements will work fine!
I'm sorry, I wasn't
I'm sorry, I wasn't completely correct. While dots are not allowed in variable names, they are of course in array keys, so
$test['test.array.here'] = 'Here is my test message';is valid php.However, the Drupal theme system takes an array with variables and extracts the contents into separate variables with
extract($variables, EXTR_SKIP)(see http://api.drupal.org/api/function/theme_render_template/6). While doing this, array keys that would result in invalid variable names, are skipped. That would explain disappearing values.