function hijri_settings_form_submit in Hijri 8
Same name and namespace in other branches
- 7 hijri.module \hijri_settings_form_submit()
Form submit handler.
File
- ./
_hijri.module, line 59
Code
function hijri_settings_form_submit($form, &$form_state) {
// Check if our field is not already created.
if (!field_info_field('field_hijri_correction')) {
// Create the field base.
$field = array(
'field_name' => 'field_hijri_correction',
'type' => 'number_integer',
);
field_create_field($field);
}
foreach ($form_state['values']['hijri_types'] as $key => $type) {
// Create the instance.
$instance = array(
'field_name' => 'field_hijri_correction',
'entity_type' => 'node',
'bundle' => $key,
'label' => t('Hijri Date Correction'),
'description' => t('This field will save the Correction and different between months'),
'required' => FALSE,
);
if ((string) $type == (string) $key) {
$prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
if (empty($prior_instance)) {
field_create_instance($instance);
}
}
else {
$prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
if (!empty($prior_instance)) {
field_delete_instance($instance, FALSE);
}
}
}
}