function fonts_com_project_form in @font-your-face 7.2
Provides project settings form.
1 string reference to 'fonts_com_project_form'
- fonts_com_menu in modules/
fonts_com/ fonts_com.module - Implements hook_menu().
File
- modules/
fonts_com/ fonts_com.module, line 453
Code
function fonts_com_project_form($form, &$form_state) {
module_load_include('inc', 'fonts_com', 'api');
$form = array();
$projects = fonts_com_get_projects();
if (count($projects) > 0) {
$form['project'] = array(
'#type' => 'select',
'#title' => t('Project'),
'#options' => array(
'' => '-- Select a project --',
),
'#ajax' => array(
'callback' => 'fonts_com_project_ajax_callback',
'wrapper' => 'project-info',
),
);
if (isset($_SESSION['fonts_com_project']) && $_SESSION['fonts_com_project'] != '') {
$form['project']['#default_value'] = $_SESSION['fonts_com_project'];
}
// if
foreach ($projects as $project) {
$edit_link = l(t('Edit'), 'admin/config/user-interface/fontyourface/fonts_com/project/edit/' . $project->ProjectKey);
$form['project']['#options'][$project->ProjectKey] = $project->ProjectName;
// . ' ' . $edit_link;
}
// foreach
$form['project']['#options']['*new*'] = '-- Create new project --';
$form['edit_project'] = array(
'#type' => 'submit',
'#value' => t('Edit project'),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'fonts_com') . '/js/project.js',
),
),
);
}
else {
drupal_set_message('Your Fonts.com account currently contains no projects. Start by creating a new project.');
drupal_goto('admin/config/user-interface/fontyourface/fonts_com/project/new');
}
// else
$form['project_info'] = array(
'#prefix' => '<div id="project-info">',
'#suffix' => '</div>',
);
if (!empty($form_state['values']['project'])) {
$_SESSION['fonts_com_project'] = $form_state['values']['project'];
$form['project_info'] += fonts_com_project_info_form($form_state['values']['project']);
// Prevents input from setting values so default values apply.
unset($form_state['input']);
}
// if
return $form;
}