Downloads
Release notes
THE FOLLOWING IS A LIST OF CHANGES FROM THE PREVIOUS VERSION 6.x-1.x
I. The most important change is that now this module instead of creating a thousand variables, now uses an array keyed variable to save all the settings, this will reduce the intense use of the {variables} table.
II. All alters are made in a separated include file, the module will auto detect the file and the function. Follow this three steps to create a new alter functionality.
1. Define the key and a default value in nodeformsettings_elements_default() or commentformsettings_elements_default(). Starting with nfs_ (for nodeformsettings) or cfs_ (for commentformsettings). Example:
function commentformsettings_elements_default() {
return array(
'cfs_author' => 0,
'cfs_preview' => 0,
// more ...
'cfs_title' => 0,
);
}
In this case we define the key 'cfs_title' with a default value of 0 (Enabled).
This step is mandatory since it will be used by the hook_form_alter() implementation. If you don't define a key in the form of 'cfs_something' or 'nfs_something' the module will not recognize the alter.
2. Create a file in the includes directory in the form of _option_cfs_something.inc
Again, the _option_cfs_ or _option_nfs_ are mandatory. Take a look at the include directory in each module to see some examples.
3. Create a function inside the .inc file you've just created. Example
/**
* Hide the Revision log field
* Define here what exactly this code is doing, include links to URLs where you took the code if necessary.
*/
// The function must be a private function and be exactly as the file name. For this example, the filename is
// 'option_cfs_size.inc' and the function is '_option_cfs_size'. You'll have to pass as arguments &$form, $settings, $node
function _option_cfs_size(&$form, $settings, $node) {
// $settings[somekey] will contain the value, if this is equal to 1 then continue
if($settings['cfs_size'] == 1) {
// Perform the alter operation
$form['cfs_filter']['comment']['#rows'] = $settings['cfs_size'];
}
// Return the $form
return $form;
}
5. Create the settings in inclues/settings_node.inc or includes/settings_comments.inc
If your alter needs some kind of validation, follow this additional steps:
6. Add the key to nodeformsettings_elements_validate(). Example:
function nodeformsettings_elements_validate() {
return array(
'nfs_title_create',
'nfs_title_edit',
);
}
7. Create a .inc file inside the includes directory. The file must start with validate_mykey, Example validate_nfs_title_create.inc
8. Inside that file add the validation function like the following:
function _validate_nfs_title_edit($form, &$form_state) {
if($form_state['values']['nfs_title_edit'] == '') {
form_set_error('nfs_title_edit', t("<em>Page title when editing a node</em> cannot be empty"));
}
}
III. All the comment form settings are now in a new module. Using it's own variable.
IV. Better features integration via strongarm.
V. Cleaner code
VI. Many bugs fixed and several new features.