I'm using Jquery Tag it and I would like to save the entered tag into my DB.
In HTML
<ul id="myTags" name="myTags"></ul>
When I entered a new tag , it will auto generate a <li>
and <input hidden>
,
But all the generated <input hidden>
are same name="tags" only the value are different , then when I $_POST
and try to print_r
, the result are only the last value that I entered.
How do I get all the value ? or any other good suggestion ? Thanks
public function actionSubmit(){
$token = $_POST['YII_CSRF_TOKEN'];
if ($token !== Yii::app()->getRequest()->getCsrfToken()){
Yii::app()->end();
}
$app_id = Yii::app()->user->getState('app_id');
$tags = $_POST['tags'];
$model = Games::model()->findByAttributes(array('id'=>$app_id));
$model->keywords = $tags;
$model->save();
if($model->save()){
print_r("ok");
}else{
print_r("no");
}
}