Form submission
Module -> phpfox_sample ->
Template -> Default -> Controller
usersubmit.html.php
<form name="form"
method="post" action="{url link='product.usersubmit'}"
enctype="multipart/form-data">
Name : <input type="text"
name="val[name]"> <br><br>
Content : <input type="text"
name="val[content]"><br><br>
<input type="submit"
name="val[submit]" > </br>
</form>
{if isset($return)}
<br><br>
successfully Added<br><br>
User id : {$return.id}<br>
Privacy : {$return.privacy}
{/if}<br><br>
Module -> phpfox_sample ->
Include -> Component -> Controller
userdisplay.class.php
class
Product_Component_Controller_Usersubmit extends Phpfox_Component
{
public function process()
{
if($aVals =
$this->request()->get('val')){
unset($aVals['submit']);
// d($aVals);
// exit();
$return =
Phpfox::getService('product.usersubmit')->insert($aVals);
// $id = $return['id'];
// $privacy=
$return['privacy'];
//$this->template()->assign(array('id'=>$id,'privacy'=>$privacy));
$this->template()->assign(array('return'=>$return));
}
}
}
Module -> phpfox_sample ->
Include -> Service
userdisplayservice.class.php
class Product_Service_Usersubmit
extends Phpfox_Service
{
/**
*function to insert value to
database (two tables)
* @param type $argument
* @return type id, privacy
* @author Arun george
<arun@arun-g.in>
* @since 22-11-2012
*
*/
function insert($argument)
{
$nameArray['name'] =
$argument['name'];
$id =
$this->database()->insert(Phpfox::getT('newuser'),$nameArray);
$contentArray['content'] =
$argument['content'];
$contentArray['privacy'] =
$id;
$privacy = \
$this->database()->insert(Phpfox::getT('usercontent'),$contentArray);
$return['id'] =
$id;
$return['privacy'] =
$privacy;
return $return ;
}
}