Forum Activity for @the-patria-company

PatriaCo
@the-patria-company
03/14/19 12:12:08PM
349 posts

New Custom Account Tab


Jamroom Developers

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(); // Form init $_tmp = array( 'submit_value' => 3, 'cancel' => jrCore_is_profile_referrer(), 'form_ajax_submit' => false, 'values' => $_profile ); jrCore_form_create($_tmp); // Profile ID $_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); } // custom_id $_tmp = array( 'name' => 'custom_id', 'type' => 'hidden', 'value' => $_custom['_item_id'] ); jrCore_form_field_create($_tmp); // Custom Description $_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)
{ // Must be logged in jrUser_session_require_login(); jrCore_form_validate($_post); jrUser_check_quota_access('MyCustomModule'); $_data = jrCore_form_get_save_data('MyCustomModule', 'settings', $_post); //remove debug after tests $_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!
PatriaCo
@the-patria-company
03/14/19 08:44:12AM
349 posts

New Custom Account Tab


Jamroom Developers

@michael Thank you!

When I perform the debug I am not getting any data to populate for this:

// custom_id
    $_tmp = array(
        'name'  => 'custom_id',
        'type'  => 'hidden',
        'value' => $_custom['_item_id']
    );
    jrCore_form_field_create($_tmp);

I am seeing the $_data for this textarea field when I enter data (so I am doing something right):

// Custom Description
    $_tmp = array(
        'name'     => 'custom_desc',
        'label'    => 4,
        'help'     => 5,
        'type'     => 'textarea',
        'validate' => 'printable',
        'required' => false
    );
    jrCore_form_field_create($_tmp);

What do I need to do to ensure that an _item_id is generated?
updated by @the-patria-company: 03/14/19 08:44:42AM
PatriaCo
@the-patria-company
03/13/19 06:36:15PM
349 posts

New Custom Account Tab


Jamroom Developers

@michael Thank you. I tried your debug code and noticed that the $_post data is NOT passing into the $_data variable.
So this is not working:
$_data = jrCore_form_get_save_data('myCustomModule', 'settings', $_post);

What should I do next?
updated by @the-patria-company: 03/13/19 06:36:35PM
PatriaCo
@the-patria-company
03/13/19 04:38:51PM
349 posts

New Custom Account Tab


Jamroom Developers

This is the data that my form currently creates:
Array ( 
[_uri] => /custom/settings_save
[jr_html_form_token] => 13a96ce33f4ae8d9b265203bf9a7ea4f
[jr_html_form_profile_id] => 1
[profile_id] => 1
[seo_metadesc] => hello you
[module_url] => custom
[module] => myCustomModule
[option] => settings_save
 )

I tried using 'profile_id', but it did not work:
function view_myCustomModule_settings_save($_post, $_user, $_conf)
{ // Must be logged in jrUser_session_require_login(); jrCore_form_validate($_post); jrUser_check_quota_access('myCustomModule'); $_data = jrCore_form_get_save_data('myCustomModule', 'settings', $_post); jrCore_db_update_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(); }

Any other data point I could use?
PatriaCo
@the-patria-company
03/13/19 07:59:21AM
349 posts

New Custom Account Tab


Jamroom Developers

I checked that and all the data from the form shows in the debug log.

But I still cannot get the data to post to the datastore. Plus, I need to make sure there is only one entry per profile_id.

function view_myCustomModule_settings_save($_post, $_user, $_conf)
{ // Must be logged in jrUser_session_require_login(); jrCore_form_validate($_post); jrUser_check_quota_access('myCustomModule'); $_data = jrCore_form_get_save_data('myCustomModule', 'settings', $_post); jrCore_db_update_item('myCustomModule', $_data); jrCore_form_delete_session(); jrUser_reset_cache($_user['_user_id']); jrCore_set_form_notice('success', 6); jrCore_form_result(); }

Thanks!!
PatriaCo
@the-patria-company
03/11/19 09:06:38AM
349 posts

New Custom Account Tab


Jamroom Developers

Good morning! :)

So I am attempting to implement the syntax found here: https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1023/datastores

So far on my Account Settings Page View I have the tab with proper link working (from includes.php), I have a profile id button and I can see the form designer button :) I also have one text area available.

PROBLEM: I am saving an empty set to the datastore (no data at all, that I can see).

//------------------------------
// settings
//------------------------------
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(); // Form init $_tmp = array( 'submit_value' => 3, 'cancel' => jrCore_is_profile_referrer(), 'form_ajax_submit' => false, 'values' => $_profile ); jrCore_form_create($_tmp); // If we modifying FROM the Profile Browser, we redirect there on save... $ref = jrCore_get_local_referrer(); if (jrUser_is_admin() && strpos($ref, '/browser')) { $_tmp = array( 'name' => 'from_browser', 'type' => 'hidden', 'value' => $ref ); 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); } // Meta Description $_tmp = array( 'name' => 'seo_metadesc', 'label' => 4, 'help' => 5, 'type' => 'textarea', 'validate' => 'printable', 'required' => false ); jrCore_form_field_create($_tmp); jrCore_page_display(); } //------------------------------ // settings_save //------------------------------ function view_myCustomModule_settings_save($_post, $_user, $_conf)
{ // Must be logged in jrUser_session_require_login(); jrCore_form_validate($_post); jrUser_check_quota_access('myCustomModule'); $_data = jrCore_form_get_save_data('myCustomModule', 'settings', $_post); $id = jrCore_db_create_item('myCustomModule', $_data); $_temp = jrCore_db_get_item('myCustomModule', $id); $_more = array(); jrCore_db_update_item('myCustomModule', $id, $_more); jrCore_form_delete_session(); jrUser_reset_cache($_user['_user_id']); jrCore_set_form_notice('success', 6); jrCore_form_result(); }

Could someone please help me out with what I am missing? THANKS!!! :)
PatriaCo
@the-patria-company
03/10/19 08:01:59PM
349 posts

New Custom Account Tab


Jamroom Developers

Thanks Steve! @ultrajam

Looking closer I think I need to first fill a variable with the form data

$_data = jrCore_form_get_save_data('myCustomModule', 'custom', $_post);

But since I want this module's data to be treated like an array of "settings" that will only be allowed once per profile, I am not sure how (or if I need to) assign the $pid to the data being saved.

Any help is much appreciated. THANKS!!
PatriaCo
@the-patria-company
02/26/19 11:23:03AM
349 posts

New Custom Account Tab


Jamroom Developers

Thank you :) I am a couple steps closer.
#1. I can see my Tab Title. :)

#2. In looking at jrProfile I added something similar to your suggestion to my include.php:
// Allow admin to customize our forms
    jrCore_register_module_feature('jrCore', 'designer_form', 'myCustomModule', 'create');
    jrCore_register_module_feature('jrCore', 'designer_form', 'myCustomModule', 'settings');
Unfortunately, the Form Designer button is still not showing.

#3. I successfully added a textarea box to my form, but the data is not populating in the datastore:
function view_myCustomModule_custom($_post, $_user, $_conf)
{ ... // Some Info $_tmp = array( 'name' => 'custom_info', 'label' => 4, 'help' => 5, 'type' => 'textarea', 'validate' => 'printable', 'required' => false ); jrCore_form_field_create($_tmp); ... jrCore_page_display(); }

I think the error is in my save function, which I don't understand yet fully.

function view_myCustomModule_custom_save($_post, $_user, $_conf)
{ // Must be logged in jrUser_session_require_login(); jrCore_form_validate($_post); jrUser_check_quota_access('myCustomModule'); // get info about this profile $_pr = jrCore_db_get_item('jrProfile', $pid); $_data = array(); jrCore_form_delete_session(); jrProfile_reset_cache($pid); jrUser_reset_cache($_user['_user_id']); jrCore_set_form_notice('success', 13); jrCore_form_result(); }

When I add data and click submit, I receive the success message, but the datastore is empty.
PatriaCo
@the-patria-company
02/24/19 07:41:38PM
349 posts

New Custom Account Tab


Jamroom Developers

So far I have an empty tab

jrCore_register_module_feature('jrUser', 'account_tab', 'myCustomModule', 'custom', 1);

And I have an empty page in the profile account area:

function view_myCustomModule_custom($_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(); // Form init $_tmp = array( 'submit_value' => 3, 'cancel' => jrCore_is_profile_referrer(), 'form_ajax_submit' => false, 'values' => $_profile ); jrCore_form_create($_tmp); // Profile ID $_tmp = array( 'name' => 'pid', 'type' => 'hidden', 'value' => intval($_profile['_profile_id']) ); jrCore_form_field_create($_tmp); jrCore_page_display(); }

How do I get my tab title to appear?

And how do I make the [form designer] available? (I already have the datastore set up in the schema.php)

Thanks for any help on this :)
updated by @the-patria-company: 02/24/19 07:42:34PM
PatriaCo
@the-patria-company
02/21/19 07:19:19AM
349 posts

New Custom Account Tab


Jamroom Developers

I need a page that appears in the "Account Settings" area. Like [profile],[account],[networks]. I looked for some documentation on this subject, but I did not find it. I can see in the Tweaks module that I need a view function that has a
jrUser_account_tabs('myModuleName', $_profile);

So I am sure that I am looking at the correct code section. I was hoping there was a "getting started" document for creating this type of page for a custom module. Again, all I need is a blank page with a [form designer] button.

Thanks!!
  3