TRUE,
'#process' => array('ife_fieldset_process'),
);
$type['textfield'] = array(
'#input' => TRUE,
'#sticky' => FALSE,
'#process' => array('ife_sticky_textfield_process'),
);
$type['textarea'] = array(
'#input'=> TRUE,
'#sticky ' => FALSE,
'#process' => array('ife_sticky_textarea_process'),
);
$type['select'] = array(
'#input'=> TRUE,
'#sticky ' => FALSE,
'#process' => array('ife_sticky_select_process'),
);
$type['list'] = array(
'#input'=>TRUE,
'#element_validate' => array('ife_list_validate'),
'#process' => array('ife_list_process'),
'#sticky' => FALSE,
);
$type['other_select'] = array(
'#input'=>TRUE,
'#process' => array('ife_other_select_process'),
);
$type['copyright'] = array(
'#input' => TRUE,
'#process' => array('ife_copyright_process'),
'#element_validate' => array('ife_copyright_validate'),
);
$type['filechooser'] = array(
'#input' => TRUE,
'#path' => '',
'#model' => '',
'#collection'=>'',
'#process' => array('ife_filechooser_process'),
'#element_validate' => array('ife_filechooser_validate'),
);
$type['person'] = array(
'#input' => TRUE,
'#process' => array('ife_person_process'),
'#default_value' => array('name'=>'', 'date'=>'', 'subject'=>'', 'role' => ''),
);
$type['organization'] = array(
'#input' => TRUE,
'#process' => array('ife_org_process'),
'#default_value' => array( 'organization' => '', 'date'=>'', 'subject'=>'', 'role' => ''),
);
$type['conference'] = array(
'#input' => TRUE,
'#process' => array('ife_conf_process'),
'#default_value' => array( 'conference' => '', 'date'=>'', 'subject'=>'', 'role' => ''),
);
$type['people'] = array(
'#input' => TRUE,
'#process' => array('ife_people_process'),
);
$type['datepicker'] = array(
'#input' => TRUE,
'#process' => array('ife_datepicker_process'),
);
return $type;
}
function ife_fieldset_process($element,$edit,&$form_state)
{
// echo 'fieldset process '. $element['#collapsible'].'
';
if (isset($element['#collapsed']) && ife_fieldset_children_has_value($element))
{
unset($element['#collapsed']);
}
return $element;
}
function ife_fieldset_children_has_value($el)
{
$ret = false;
if ((isset($el['#default_value']) && !is_array($el['#default_value']) && trim($el['#default_value']) != '') ||
(isset($el['#value']) && trim($el['#value']) != ''))
{
$ret = true;
} else
{
foreach (element_children($el) as $key)
{
if (!$ret)
{
$ret = (isset($_POST[$key]) && (is_array($_POST[$key]) || trim($_POST[$key]) != '')) || ife_fieldset_children_has_value($el[$key]);
}
}
}
return $ret;
}
function ife_people_process($element,$edit,&$form_state)
{
$element['#tree'] = TRUE;
$element['#prefix'] = '
'; var_dump($json); echo ''; drupal_set_message(ob_get_contents()); ob_end_clean(); switch ($json->type) { case 'personal': $person['name']=$json->name; $person['role']=$json->role; $person['subject']=$json->subject; $person['date']=$json->date; break; case 'organization': $person['organization'] = $json->name; $person['role'] = $json->role; $person['subject']=$json->subject; break; case 'conference': $person['conference'] = $json->name; $person['role'] = $json->role; $person['date'] = $json->date; $person['subject']=$json->subject; break; } $people[]=$person; $form_state['storage']['people']=$people; } else if (!isset($form_state['storage']['people']) || empty($form_state['storage']['people'])) { if ( (!isset($form_state['clicked_button']) || count($form_state['clicked_button']) == 0) && isset($element['#default_value']) && is_array($element['#default_value']) ) { $form_state['storage']['people']=$element['#default_value']; if (count($element['#default_value']) > 0) { $element['#collapsed'] = FALSE; } } else { $form_state['storage']['people']=array( array('name'=>'', 'role'=>'', 'date'=>'', 'subject' => '')); } } $i=0; foreach ($form_state['storage']['people'] as $person) { $person['delta'] = $i; $type='person'; if (isset($person['organization'])) { $type='organization'; } else if (isset($person['conference'])) { $type='conference'; } $element['people']['entity'.$i] = array('#type'=>$type, '#default_value'=>$person); $i++; } $element['add_from_repository'] = array( '#type' => 'textfield', '#autocomplete_path' => 'autocomplete_person/', '#weight' => 4, '#size' => 30, '#value' => '', '#title'=> t('Add entity from repository'), '#description'=>t('To add an existing entity, simply start typing the name of the person, organization or conference and select the desired name from the resulting dropdown list.') ); $element['add_person'] = array( '#type' => 'submit', '#prefix' => ' ', '#value' => t('Add Person'), '#attributes' => array('class' => 'add-person', 'title' => t('Click here to add a person.')), '#weight' => 3, '#submit' => array('ife_add_person_submit'), // If no javascript action. '#ahah' => array( 'path' => 'ife/people_ahah', 'wrapper' => 'ife-people', 'method' => 'replace', 'effect' => 'fade', ), ); $element['add_organization'] = array( '#type' => 'submit', '#prefix' => ' ', '#value' => t('Add Organization'), '#attributes' => array('class' => 'add-org', 'title' => t('Click here to add an organization.')), '#weight' => 2, '#submit' => array('ife_add_org_submit'), // If no javascript action. '#ahah' => array( 'path' => 'ife/people_ahah', 'wrapper' => 'ife-people', 'method' => 'replace', 'effect' => 'fade', ), ); $element['add_conference'] = array( '#type' => 'submit', '#prefix' => ' ', '#value' => t('Add Conference'), '#attributes' => array('class' => 'add-conf', 'title' => t('Click here to add a conference.')), '#weight' => 1, '#submit' => array('ife_add_conf_submit'), // If no javascript action. '#ahah' => array( 'path' => 'ife/people_ahah', 'wrapper' => 'ife-people', 'method' => 'replace', 'effect' => 'fade', ), ); return $element; } function ife_person_process($element) { $element['#tree'] = TRUE; if (!isset($element['#value'])) { $element['#value'] = array('name'=>''); } $element['name'] = array( '#type' => 'textfield', '#title'=> t('Name(s)'), '#size' => 30, '#value' => $element['#value']['name'], '#description' => t('Please enter last name first, followed by a comma and first name.'), ); $element['date'] = array( '#type' => 'datepicker', '#title' => t('Date'), '#size'=> 30, '#value' => $element['#value']['date'], '#description' => '
'; var_dump($element); echo ''; //return theme('theme_form_element', $element, '