So here is what I have currently (I am using "custom" for the sake of the forum, but I have verified that my schema is working):
Here is my view form function, which does show me one textarea and the [Form Designer] button. In this example I open the Form and entered "New Attempt" in the Textarea and clicked save. I then received a success message; however, an empty entry was made into the datastore.
function view_myCustomModule_settings($_post, $_user, $_conf)
{
global $_mods;
jrUser_session_require_login();
jrUser_check_quota_access('myCustomModule');
if (!isset($_post['profile_id']) || !jrCore_checktype($_post['profile_id'], 'number_nz') || !jrProfile_is_profile_owner($_post['profile_id'])) {
$_post['profile_id'] = jrUser_get_profile_home_key('_profile_id');
}
$_profile = jrUser_get_requested_user_account_info();
if (!$_profile || !is_array($_profile)) {
jrCore_notice_page('error', 41);
}
jrUser_account_tabs('custom', $_profile);
$button = null;
if (!empty($_profile['profile_name'])) {
$button = jrCore_page_button('account-tabs-profile-button', "@{$_profile['profile_url']}", "jrCore_window_location('{$_conf['jrCore_base_url']}/{$_profile['profile_url']}')");
}
$_ln = jrUser_load_lang_strings();
jrCore_page_banner(2, $button);
jrCore_get_form_notice();
$_tmp = array(
'submit_value' => 3,
'cancel' => jrCore_is_profile_referrer(),
'form_ajax_submit' => false,
'values' => $_profile
);
jrCore_form_create($_tmp);
$_tmp = array(
'name' => 'pid',
'type' => 'hidden',
'value' => intval($_profile['_profile_id'])
);
jrCore_form_field_create($_tmp);
if ((jrUser_is_admin() || jrUser_is_power_user() || jrUser_is_multi_user()) && isset($_post['profile_id']) && jrCore_checktype($_post['profile_id'], 'number_nz')) {
$_tmp = array(
'name' => 'profile_id',
'type' => 'hidden',
'value' => $_post['profile_id']
);
jrCore_form_field_create($_tmp);
}
$_tmp = array(
'name' => 'custom_id',
'type' => 'hidden',
'value' => $_custom['_item_id']
);
jrCore_form_field_create($_tmp);
$_tmp = array(
'name' => 'custom_desc',
'label' => 4,
'help' => 5,
'type' => 'textarea',
'validate' => 'printable',
'required' => false
);
jrCore_form_field_create($_tmp);
jrCore_page_display();
}
This form is generating data for $_post
[$_post] => Array (
[_uri] => /custom/settings_save
[jr_html_form_token] => 4a2a85f2898ad82ee143df4c35a055c5
[jr_html_form_profile_id] => 1
[pid] => 1
[profile_id] => 1
[custom_id] =>
[custom_desc] => New Attempt
[module_url] => custom
[module] => myCustomModule
[option] => settings_save
)
Next, I set up a save view function. This is where I am getting hung up, but I am sure I also have an issue in the form above since I can't get the _item_id to populate.
function view_MyCustomModule_settings_save($_post, $_user, $_conf)
{
jrUser_session_require_login();
jrCore_form_validate($_post);
jrUser_check_quota_access('MyCustomModule');
$_data = jrCore_form_get_save_data('MyCustomModule', 'settings', $_post);
$_debug = array(
'WHAT' => 'Im trying to figure out what I have in this location',
'$_data' => $_data,
'$_post' => $_post,
);
fdebug($_debug);
jrCore_db_create_item('MyCustomModule', $_data['profile_id'], $_data);
jrCore_form_delete_session();
jrUser_reset_cache($_user['_user_id']);
jrCore_set_form_notice('success', 6);
jrCore_form_result();
}
The debug is also telling me that my $_data is populating, although the _item_index is empty.
[$_data] => Array (
[custom_id] =>
[custom_desc] => New Attempt
)
I hope this helps to clarify my dilema. Thanks!
--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3