0

I'm altering an existing Joomla 2.5 component and I wish to add data to a specific table (already existent upon install) to a couple custom columns. So, I have this view (_quizInfo.php on the quiz view folder) code which consists of a form that displays some information (retrieved from the DB) and to proceed upon a checkbox being checked to another view (the quiz view). (Basically, it's a couple JS lines enabling the "proceed" button). Heres the (simplified) code:

<?php defined( '_JEXEC' ) or die( 'Restricted access' ); ?>

<script type="text/javascript" language="javascript">

function proceed()
{
    check = document.getElementById('checkToProceed') ;
    proceedButton = document.getElementById('proceedButton') ;

    if (check.checked) {
        proceedButton.disabled = false ;
    } else {
        proceedButton.disabled = true ;
    }
}

</script>

<form name="quiz_info" method="post">

<?php 
echo '<div class="items-row"><div class="item">';

    echo '<h2>' . JText::sprintf('YOU_HAVE_CHOSEN_TO_TAKE_QUIZ', '"'.$this->quiz- >title.'"') . '</h2>' ;

echo '<ul>' ;

...

echo '</ul>' ;
$option = JRequest::getCmd('option');

$link =  JRoute::_('index.php?option='. $option . '&controller=quiz&layout=default') ;

echo '<p><input type="checkbox" id="checkToProceed" name="checkToProceed" onclick="proceed();" /><label for="checkToProceed">' . JText::_('I_HAVE_READ_AND_UNDERSTOOD') . '</label></p>' ;
echo '<input id="proceedButton" name="proceedButton" disabled="true" value="' . JText::_('PROCEED_TO_QUIZ') . '" type="submit" />' ;

    echo '</div></div>';
?>

<input type="hidden" name="option" value="com_jquarks" />
<input type="hidden" name="id" value="<?php echo $this->quiz->id ; ?>"/>
<input type="hidden" name="task" value="showQuiz" />
<input type="hidden" name="view" value="quiz" />
<input type="hidden" name="layout" value="default" />
<?php echo JHTML::_( 'form.token' );  ?> 

Now, I've added a form to this page so a user can fill out his/her data and then proceed (I need this data at this step to be stored), so now besides the code already showed I've added the following lines on the form tag:

//Added
echo '<li><p>' . JText::sprintf('Before proceeding you must fill the form bellow:') . '</p></li>' ;

echo '<div style="width: 50%; border: 1px solid; padding: 15px;"><form><div style="width: 100px">Full Name: </div><input type="text" name="fullname" style="width: 100%;"><br/><div style="width:100px"><br>ID document: </div><input type="text" name="iddoc" style="width: 100%;"></form></div>';
//END Added

I've noticed that the form is of POST type but there is no action defined. The quiz view then stores all the necessary data before displaying the quiz (on the intended table) but I don't know how to proceed to store the _quizInfo view form data in the DB since it apparently isn't supposed to store anything. The "session" is only stored (on the corresponding table) after clicking proceed and the quiz view is called.

Can anyone point me in the right direction? Not really comfortable with the way Joomla handles DB calls.

-Should I capture the POST data on the default.php file of the quiz view?

-Should I store the form data immediately?

Any help would be greatly appreciated.

Best Regards

4

1 回答 1

0

好吧,我最终找到了我的问题的答案,我将把它留给任何需要它的人:

任何作为 POST 或 GET 传递的数据,即使没有明确的目标/动作定义(因为我们正在使用 MVC),也可以使用 JRequest::getVar() 或 JRequest::get() 来访问,如此处的文档:http: //docs.joomla.org/Retrieving_and_Filtering_GET_and_POST_requests_with_JRequest:: getVar

于 2013-04-22T17:18:13.427 回答