I created a module for EE2 a few years back and I'm in the process of making this compatible with EE3/4. I'd ideally like to make use of the ee:_shared/form
(Shared Form View) and I'm 90% there but struggling with image field types. Text fields are working perfectly fine.
user/addons/module_name/mcp.module_name.php
public function add()
{
if ( ! ee()->cp->allowed_group('can_access_content'))
{
show_error(lang('unauthorised_access'));
}
$vars = array(
'base_url' => ee('CP/URL', 'addons/settings/' . $this->lower . '/update'),
'cp_page_title' => lang('add'),
'save_btn_text' => 'btn_add',
'save_btn_text_working' => 'btn_saving'
);
$vars['sections'] = array(
$this->get_sections()
);
return ee('View')->make('module_name:form')->render($vars);
}
// $this->get_sections() returns the following nested arrays
// This is working fine for text fields
$sections[] = array(
'title' => $field,
'fields' => array(
$field => array(
'type' => $type,
'value' => $value,
'required' => $required
)
)
);
user/addons/module_name/View/form.php
<?php $this->embed('ee:_shared/form'); ?>
I'm guessing I need to use the ee('CP/FilePicker') Service
for something but the documentation is very vague.
I appreciate this is an incredibly vague query but does anyone have experience with setting up a file/image field using EE's shared form view?