Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
2.5k views
in Q2A Core by
edited by

I am trying to add form element to Ask a question page but getting trouble to add element by layer. I have tried to add by layer with three different function but with this not adding element into the form but outside the form.

 

function form($form)
{
qa_html_theme_base::form($form);
$this->output('Here will be new input element');
}
 
function form_body($form)
{
qa_html_theme_base::form_body($form);
$this->output('Here will be new input element');
}
 
function form_buttons($form, $columns)
{
qa_html_theme_base::form_buttons($form, $columns);
$this->output('Here will be new input element');
}
 
I am also confuse should I have to use temple as below to get only for Ask page? ro there is any different way to do
 
if ($this->template == 'ask')
$this->output('Here will be new input element');
 
I am sure some one must have solution for this.

EDIT:-----------------------------------------------------------------------------------

At last got it work and store value to db but now have one trouble. I want this field only on Ask a question page and on edit question form but with $this->template of course its adding all single question page forms.

Need help here is the code

 

function form_buttons($form, $columns)
{
 
if(($this->template == 'ask' OR $this->template == 'question') AND qa_get_logged_in_level() > QA_USER_LEVEL_ADMIN):
 
$this->my_check(); // this is my custom checkbox input code
 
endif;
 
qa_html_theme_base::form_buttons($form, $columns);
 
}

1 Answer

+1 vote
by
selected by
 
Best answer

You can check if ($this->context['part']=='form_q_edit') within the theme to see if you are in the middle of outputting a question editing form.

by
Gideon,
Thanks a lot. will give it a try and get back to you.
by
Wonderful! It's resolved my issue. By the way where I can see this in core file?
by
'form_q_edit' is used as the page part name in qa-page-question.php
by
Thanks a lot...!
...