Ref: https://www.packtpub.com/sites/default/files/9781849516808-Chapter-3.pdf
Create custom field type
1. in .module, implement hook_field_info
'default_widget'=> 'widget_name'
which we will implement later in hook_field_widget_info.
1.1 implement hook_field_validate & hook_field_is_empty as required.
2. in .module, implement hook_field_widget_info to make drupal aware of our custom widget
$widgets['widget_name'] = array( ...)
3. implement hook_field_widget_form to actually add the form components to the node form
Save and install module.
Use the custom field type
1. Admin > Structure , select content type and manage fields.
Now you can see the custom field type available in the "field type" pull down list .
沒有留言:
張貼留言