function hook_widget_settings in Content Construction Kit (CCK) 5
Handle the parameters for a widget.
Parameters
$op: The operation to be performed. Possible values:
- "form": Display the widget settings form.
- "validate": Check the widget settings form for errors.
- "save": Declare which pieces of information to save back to the database.
- "callbacks": Describe the widget's behaviour regarding hook_widget operations.
$widget: The widget on which the operation is to be performed.
Return value
This varies depending on the operation.
- "form": an array of form elements to add to the settings page.
- "validate": no return value. Use form_set_error().
- "save": an array of names of form elements to be saved in the database.
- "callbacks": an array describing the widget's behaviour regarding hook_widget operations. The array is keyed by hook_widget operations ('form', 'validate'...) and has the following possible values : CONTENT_CALLBACK_NONE : do nothing for this operation CONTENT_CALLBACK_CUSTOM : use the behaviour in hook_widget(operation) CONTENT_CALLBACK_DEFAULT : use content.module's default bahaviour Note : currently only the 'default value' operation implements this feature. All other widget operation implemented by the module _will_ be executed no matter what.
2 functions implement hook_widget_settings()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- text_widget_settings in ./
text.module - Implementation of hook_widget_settings().
- userreference_widget_settings in ./
userreference.module - Implementation of hook_widget_settings().
3 invocations of hook_widget_settings()
- _content_admin_field in ./
content_admin.inc - Menu callback; presents the field editing page.
- _content_admin_field_submit in ./
content_admin.inc - Save a field's settings after editing.
- _content_admin_field_validate in ./
content_admin.inc - Validate a field's settings.
File
- ./
field.php, line 351 - These hooks are defined by field modules, modules that define a new kind of field for insertion in a content type.
Code
function hook_widget_settings($op, $widget) {
switch ($op) {
case 'form':
$form = array();
$form['rows'] = array(
'#type' => 'textfield',
'#title' => t('Rows'),
'#default_value' => $widget['rows'] ? $widget['rows'] : 1,
'#required' => TRUE,
);
return $form;
case 'validate':
if (!is_numeric($widget['rows']) || intval($widget['rows']) != $widget['rows'] || $widget['rows'] <= 0) {
form_set_error('rows', t('"Rows" must be a positive integer.'));
}
break;
case 'save':
return array(
'rows',
);
case 'callbacks':
return array(
'default value' => CONTENT_CALLBACK_NONE,
);
}
}