nr_webform_fields.module in Node registration 7
File
submodules/nr_webform_fields/nr_webform_fields.moduleView source
<?php
/**
* Implements hook_form_FORM_ID_alter() for node_registration_type_settings().
*/
function nr_webform_fields_form_node_registration_type_settings_alter(&$form, &$form_state) {
$registration_type = $form['#registration_type'];
$type = $registration_type->type;
$settings = _node_registration_node_type_settings($type);
$form['events']['extra_nr_webform_fields_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Webform Fields for this type'),
'#default_value' => !empty($settings->extra_nr_webform_fields_enable),
'#description' => t('Also requires a <em>Webform Submission</em> field with any name.'),
);
}
/**
* Implements hook_webform_fields_node_methods_info().
*/
function nr_webform_fields_webform_fields_node_methods_info() {
$info = array();
$nr_types = _node_registration_node_types();
foreach ($nr_types as $type => $foo) {
$settings = _node_registration_node_type_settings($type);
if (!empty($settings->extra_nr_webform_fields_enable)) {
foreach (field_info_instances('node_registration', $type) as $field_name => $instance) {
if ($instance['widget']['type'] == 'webform_fields_widget') {
$info[$type]['node_registration:' . $type . ':' . $field_name] = array(
'title' => 'Registration custom fields',
'callback' => '_nr_webform_fields_event_node',
);
}
}
}
}
return $info;
}
/**
* Callback for webform_fields to find the event node from a NodeRegistrationEntityClass entity.
*/
function _nr_webform_fields_event_node($context) {
$form = $context['form'];
if (isset($form['#registration'])) {
$registration = $form['#registration'];
if (is_object($registration) && is_a($registration, 'NodeRegistrationEntityClass')) {
return node_load($registration->nid);
}
}
}
Functions
Name | Description |
---|---|
nr_webform_fields_form_node_registration_type_settings_alter | Implements hook_form_FORM_ID_alter() for node_registration_type_settings(). |
nr_webform_fields_webform_fields_node_methods_info | Implements hook_webform_fields_node_methods_info(). |
_nr_webform_fields_event_node | Callback for webform_fields to find the event node from a NodeRegistrationEntityClass entity. |