Trycaiocald wrote: ↑Thu Dec 20, 2018 1:12 amCode: Select all
$topic_id = $this->request->variable('topic_id',0);
t
instead of topic_id
Trycaiocald wrote: ↑Thu Dec 20, 2018 1:12 amCode: Select all
$topic_id = $this->request->variable('topic_id',0);
t
instead of topic_id
Toxyy wrote: ↑Thu Dec 20, 2018 1:29 amTrycaiocald wrote: ↑Thu Dec 20, 2018 1:12 amCode: Select all
$topic_id = $this->request->variable('topic_id',0);
t
instead oftopic_id
Code: Select all
$topic_id = $this->request->variable('t',0);
When are you callingcaiocald wrote: ↑Thu Dec 20, 2018 1:58 amToxyy wrote: ↑Thu Dec 20, 2018 1:29 amTrycaiocald wrote: ↑Thu Dec 20, 2018 1:12 amCode: Select all
$topic_id = $this->request->variable('topic_id',0);
t
instead oftopic_id
return 0Code: Select all
$topic_id = $this->request->variable('t',0);
formulariopontuacao()
?$this->request->variable('t', '');
When the user clicks the submit form buttonWhen are you callingformulariopontuacao()
?
Also try:$this->request->variable('t', '');
Code: Select all
$topic_id = $this->request->variable('t', '');
Show me this in your github, likely you'll need to add the topic id into the form itself with a hidden input, then you'll be able to pull the data with a request var.
OMG
Code: Select all
<input type="hidden" name="topic_id" value="">
Code: Select all
<input type="hidden" name="topic_id" value="<?= echo"$_GET['t']";?>">
Code: Select all
<!-- PHP -->echo "$_GET['t']";<!-- ENDPHP -->
$topic_id = $this->request->variable('t', 0);
(where t is the name attribute of your input field or parameter).Mr. Goldymrgoldy wrote: ↑Thu Dec 20, 2018 9:08 am All nice and dandy it is in the current URL, but if it is not in your form action URL you will not be able to request it.
So you either have to append it to your form action's URL or add a hidden input field with the current topic identifier as a value.
Then upon submission you can request it with$topic_id = $this->request->variable('t', 0);
(where t is the name attribute of your input field or parameter).
Code: Select all
<form action="post" action="{{ U_YOUR_FORM_ACTION }}">
<!-- YOUR_FORM_ACTION should include &t=5
or you can use an hidden input like below -->
<input name="t" type="hidden" value="5">
...
<input class="button1" id="submit" name="submit" type="submit" value="{{ lang('SUBMIT') }}">
</form>
Code: Select all
<?php
namespace vendor\extension\controller;
class main_controller
{
/** @var \phpbb\request\request */
protected $request;
public function __construct(\phpbb\request\request $request)
{
$this->request = $request;
}
public function handle()
{
// if the form is submitted
if ($submit = $this->request->is_set_post('submit'))
{
// request the form variables
$topic_id = $this->request->variable('t', 0);
// Do your thing
}
}
}
return 0mrgoldy wrote: ↑Thu Dec 20, 2018 2:51 pm There is no way to "analyze" your code, as you do not have a link to your GitHub repository.
And please do not see this as an invite to attach a zip here or in a private message.
And well, what can I say, if you can not manage to request an input variable from a form, there is a long road ahead of you.
Anyways, this is the best example I can give you:Code: Select all
<form action="post" action="{{ U_YOUR_FORM_ACTION }}"> <!-- YOUR_FORM_ACTION should include &t=5 or you can use an hidden input like below --> <input name="t" type="hidden" value="5"> ... <input class="button1" id="submit" name="submit" type="submit" value="{{ lang('SUBMIT') }}"> </form>
Code: Select all
<?php namespace vendor\extension\controller; class main_controller { /** @var \phpbb\request\request */ protected $request; public function __construct(\phpbb\request\request $request) { $this->request = $request; } public function handle() { // if the form is submitted if ($submit = $this->request->is_set_post('submit')) { // request the form variables $topic_id = $this->request->variable('t', 0); // Do your thing } } }
Hi, Canonknipsercanonknipser wrote: ↑Thu Dec 20, 2018 6:11 pm I would suggest to try the skeleton tool to check out the way extension coding work in their different context (acp, ucp, mcp, standard page ...)