Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Store 3 Input Fields (Date: Year, Month, Day) Into 1 Database Field ('date')

$
0
0
I would like to store 3 input fields in 1 mysql database field, named 'date'. In stead of storing a date in the yyyy-mm-dd format, it only stores the word 'array'... Can anybody help?

View
<? echo CHtml::activeDropDownList($page, 'date[day]', CHtml::listData($day, 'id', 'name')); ?>
<? echo CHtml::activeDropDownList($page, 'date[month]', CHtml::listData($month, 'id', 'name')); ?>
<? echo CHtml::activeDropDownList($page, 'date[year]', CHtml::listData($year, 'id', 'name')); ?>


Controller
public function actionPage() 
{
  $page = new Page;
		
		if(isset($_POST['Page']))
		{
			
			$page->birthdate = implode("-", $_POST['Page']['date']);	
			$page->attributes = $_POST['Page'];
			$page->save();
		}
				
	}

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>