I am creating a new extension and from it I want to create a new extension, I was trying to do this but is not working, please any ideas? The problem is that form_helper is not working, i think because I don't have the folder /phpbb/form/helper
I am getting this message: You have requested a non-existent service
I am using phpbb 3.2.8
or there is another way to do it?.
Please advise
thanks a lot in advance!
Code: Select all
global $phpbb_container;
$this->container = $phpbb_container;
$form_helper = $this->container->get('form_helper');
// Set the form data
$form_data = array(
'forum_name' => $permalink,
'forum_desc' => 'This is my new forum',
'parent_id' => 67, // set the parent forum ID here
);
// Build the form
$form_helper->set_form_key('acp_forums');
$form_helper->add_hidden_field('mode', 'new');
$form_helper->add_hidden_field('i', 'acp_forums');
foreach ($form_data as $key => $value) {
$form_helper->add_text_field($key, $value);
}
// Submit the form
$form_url = append_sid($phpbb_root_path . 'adm/index.php');
$response = $form_helper->submit_form($form_url);
// Check for errors
if ($response->get_error_code() !== false) {
// There was an error creating the forum
echo 'Error: ' . $response->get_error_message();
} else {
// The forum was created successfully
echo 'Forum created successfully';
}