solved Question about form field

Melih
Melih
@melih
8 years ago
198 posts
Hello guys, I hope you are all ok!
I want to ask something, i hope i can explain clearly;

I want to add a new field to profile settings page (site.com/profile/settings/profile_id=???) but i don't want to use form designer or edit jrProfile's php files. Is there a way to add a field to a module from another module? I have a custom module which i created for some additional functions. If it's possible i want this field to be added by my custom module. Note that i have very limited coding experience and knowledge.
updated by @melih: 03/08/17 04:15:50PM
paul
@paul
8 years ago
4,331 posts
It is possible - you'd need to add a 'form_display' listener to your custom module and code that to detect the profile/settings forum then insert the field. Plenty of Jamroom modules do this. Here's the listener code from the Birthday module so maybe you can use that as a guide -
function jrBirthday_form_display_listener($_data, $_user, $_conf, $_args, $event)
{ if (isset($_data['form_view']) && $_data['form_view'] == 'jrUser/account') { // Add in birthdate field $_ln = jrUser_load_lang_strings(); $_tm = array( 'name' => 'user_birthdate', 'label' => $_ln['jrBirthday'][1], 'sublabel' => $_ln['jrBirthday'][3], 'help' => $_ln['jrBirthday'][2], 'type' => 'date_birthday', 'validate' => 'date_birthday', 'exclude_year' => true, 'required' => false, 'form_designer' => false ); jrCore_form_field_create($_tm); } return $_data; }
hth


--
Paul Asher - JR Developer and System Import Specialist
Melih
Melih
@melih
8 years ago
198 posts
Wow, thank you very much @paul! I will try it right away. And thanks for the tip ;)
updated by @melih: 12/08/16 07:19:06AM
paul
@paul
8 years ago
4,331 posts
Don't forget to 'register' the listener in the custom module init function -
    jrCore_register_event_listener('jrCore', 'form_display', 'jrBirthday_form_display_listener');



--
Paul Asher - JR Developer and System Import Specialist
Melih
Melih
@melih
8 years ago
198 posts
Yeap i saw that, thank you!
Melih
Melih
@melih
8 years ago
198 posts
@Paul, it worked perfectly. Thanks again!
paul
@paul
8 years ago
4,331 posts
np - Glad it worked out :-)


--
Paul Asher - JR Developer and System Import Specialist

Tags