Custom Form Design
Jamroom Developers
ok, got something.
There are probably multiple ways to do this, but this one works. The concept is, look for an 'event' that is firing when the form_field_elements.tpl is firing, AND we are in our module, then use a 'listener' to redirect to our custom version of that file for just our module.
Docs: "Events and Listeners"
https://www.jamroom.net/the-jamroom-network/documentation/development/1011/events-and-listeners
So the first step is to register the listener for the event we want, the one I chose was 'template_file', so in the _init() function for the module:
/modules/xxCreateIssue/include.php
add:
jrCore_register_event_listener('jrCore', 'template_file', 'xxCreateIssue_template_file_listener');
The whole thing probably looks something like:
function xxCreateIssue_init(){
jrCore_register_module_feature('jrCore', 'quota_support', 'xxCreateIssue', 'on');
jrCore_register_event_listener('jrCore', 'template_file', 'xxCreateIssue_template_file_listener');
return true;
}
Then under that add in this function:
function xxCreateIssue_template_file_listener($_data, $_user, $_conf, $_args, $event)
{
if ($_data['template'] == 'form_field_elements.tpl') {
$flag = jrCore_get_flag('xxCreateIssue_use_custom_tpl');
if ($flag) {
$_data['directory'] = 'xxCreateIssue';
$_data['template'] = 'form_field_elements.tpl';
jrCore_delete_flag('xxCreateIssue_use_custom_tpl');
}
}
return $_data;
}
Then copy the form_field_elements.tpl file from the core folder to:
/modules/xxCreateIssue/templates/form_field_elements.tpl
(it doesnt have to be called this, but for ease of remembering its easy)
You can see in that function above that we are looking for a flag that has been set,
xxCreateIssue_use_custom_tpl. Thats just a name I chose, it could be anything, but something unique so we know its the right one in our listener.
The last thing we need to do is set that flag during the _create() function or the update function if you use that too.
in /modules/xxCreateIssue/index.tpl in the view_xxCreateIssue_create() function, just before the jrCore_page_display() function set that flag:
jrCore_set_flag('xxCreateIssue_use_custom_tpl', true);
jrCore_page_display();
Now when the page is showin the custom version of the form_field_elements.tpl will show.
(actually thinking about it now, might need to wait longer to delete the flag if you have many page elements. Suspect you can take it from here.)
You can set a session counter or a flag to do the "count to 4 then wrap div" part.
Great to see developers working on this level. Great question.