PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function annotate_admin_settings() {$options = node_get_types('names');$form['annotate_node_types'] = array('#type' => 'checkboxes','#title' => t('Users may annotate these content types'),'#options' => $options,'#default_value' => variable_get('annotate_node_types', array('page')),'#description' => t('A text field will be available on these content types tomake user-specific notes.'),);return system_settings_form($form);}
the above are two functions and each have a return value. but the return value are all irregularly, now if i want to design a function how to write the function's return.
function annotate_admin_settings() {
$options = node_get_types('names');
$form['annotate_node_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Users may annotate these content types'),
'#options' => $options,
'#default_value' => variable_get('annotate_node_types', array('page')),
'#description' => t('A text field will be available on these content types tomake user-specific notes.')
);
return system_settings_form($form);
}
i want to know why on the above the function's return line are "return $items" and "return system_settings_form($form)", could i instead of it using others?
eg:return system_settings_form($form)", i use this "return $form" to place of it.
Of course you can change the functions so that they return different values. But if you do so, you are likely to find that your programme does not work at all, or produces strange and unpredictable outcomes.
Take your second function, annotate_admin_settings(), for example. It returns system_settings_form($form). This means that it takes the value of $form, and uses it as an input in the function system_settings_form(), and returns the output. I don't know what system_settings_form() does exactly, but I guess that it turns the array $forms into the html needed to display a form on the webpage. So changing the return value of annotate_admin_settings() to $forms would have a radical effect on this part of the programme, and would probably give you a broken Drupal installation.