Hi,
I have been messing around with creating articles from the form submissions. I have managed to find a way to do this. What I simply do is link the jos_content table to my form as well as the table that stores the data of the form.
What I do is in the "onSubmit Events Code" block, I entered the following code:
This works like a charm and creates an article for me without problems. However, it is ALWAYS creating 2 records on the table instead of 1. Is this a bug in the onSubmit event??
I have been messing around with creating articles from the form submissions. I have managed to find a way to do this. What I simply do is link the jos_content table to my form as well as the table that stores the data of the form.
What I do is in the "onSubmit Events Code" block, I entered the following code:
<?php
$row =& JTable::getInstance("content", "Table");
JRequest::setVar( "title", JRequest::getVar( "title", "New Form Submission", "post", "string"));
JRequest::setVar( "alias", JRequest::getVar( "alias", "new-form-submission", "post", "string"));
JRequest::setVar( "introtext", JRequest::getVar( "introtext", "This is the content", "post", "string"));
JRequest::setVar( "state", JRequest::getVar( "state", 1, "post", "int"));
JRequest::setVar( "sectionid", JRequest::getVar( "sectionid", 22, "post", "int"));
JRequest::setVar( "catid", JRequest::getVar( "catid", 61, "post", "int"));
JRequest::setVar( "created", JRequest::getVar( "created", date("Y-m-d")." - ".date("H:i:s"), "post", "string"));
JRequest::setVar( "created_by", JRequest::getVar( "created_by", 62, "post", "int"));
JRequest::setVar( "publish_up", JRequest::getVar( "publish_up", date("Y-m-d")." - ".date("H:i:s"), "post", "string"));
JRequest::setVar( "attribs", JRequest::getVar( "attribs", "show_title=\nlink_titles=\nshow_intro=\nshow_section=\nlink_section=\nshow_category=\nlink_category=\nshow_vote=\nshow_author=\nshow_create_date=\nshow_modify_date=\nshow_pdf_icon=\nshow_print_icon=\nshow_email_icon=\nlanguage=\nkeyref=\nreadmore=", "post", "string"));
JRequest::setVar( "metadata", JRequest::getVar( "metadata", "robots=\nauthor=", "post", "string"));
$post = JRequest::get( "post" , JREQUEST_ALLOWRAW );
if (!$row->bind( $post )) {
JError::raiseWarning(100, $row->getError());
}
if (!$row->store()) {
JError::raiseWarning(100, $row->getError());
}
?>
This works like a charm and creates an article for me without problems. However, it is ALWAYS creating 2 records on the table instead of 1. Is this a bug in the onSubmit event??