<?php
/**
* Implements hook_node_info().
*/
function non_recruiter_node_info() {
// We define the node type as an associative array.
return array(
'job_template_2' => array(
'name' => t('Job Template 2'),
'base' => 'job_template_2',
'description' => t('A content type for posting your jobs.'),
'title_label' => t('Job Template 2'),
'locked' => TRUE,
),
);
}
/**
* Implements hook_node_type_insert().
*/
function non_recruiter_node_type_insert($content_type) {
if ($content_type->type == 'job_template_2') {
$body_instance = node_add_body_field($content_type, t('Job Description'));
$body_instance['display']['non_recruiter_list'] = array(
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
);
// Save our changes to the body field instance.
field_update_instance($body_instance);
// Create all the fields we are adding to our content type.
foreach (_non_recruiter_installed_fields() as $field) {
field_create_field($field);
}
// Create all the instances for our fields.
foreach (_non_recruiter_installed_instances() as $instance) {
$instance['entity_type'] = 'node';
$instance['bundle'] = 'job_template_2';
field_create_instance($instance);
}
}
}
/**
* Implements hook_form().
*/
function job_template_2_form($node, $form_state) {
return node_content_form($node, $form_state);
}
function _non_recruiter_installed_fields() {
return array(
'non_recruiter_quantity' => array(
'field_name' => 'node_example_quantity',
'cardinality' => 1,
'type' => 'text',
),
);
}
function _non_recruiter_installed_instances() {
return array(
'non_recruiter_quantity' => array(
'field_name' => 'node_example_quantity',
'label' => t('Quantity required'),
'type' => 'text',
'widget' => array(
'type' => 'text_textfield',
),
'display' => array(
'non_recruiter_list' => array(
'label' => 'hidden',
'type' => 'hidden',
),
),
),
);
}
There is unmatched value for key 'field_name' => 'non_recruiter_quantity' in the function _non_recruiter_installed_fields() and _non_recruiter_installed_instances() do it similar as you wanna I have tested. problem resolved.
Manoj Paul
- 44
- 6