Page 1 of 1
data from Dropdownlist not inserting into database
#1
Posted 02 November 2010 - 08:12 AM
i have two mdoel 1)Issue
2)Category
and in the issue view page, i am able to get the data into Dropdownlist form tbl_category database
<div>
<?php echo $form->labelEx($model, 'category'); ?>
<?php echo CHtml::activeDropDownList($model, 'category_id',Category::model()->getCategoryOptions()); ?>
<?php echo $form->error($model, 'category'); ?>
</div>
but the data is not inserting into tbl_issue database
plz reply
thanks in advance
2)Category
and in the issue view page, i am able to get the data into Dropdownlist form tbl_category database
<div>
<?php echo $form->labelEx($model, 'category'); ?>
<?php echo CHtml::activeDropDownList($model, 'category_id',Category::model()->getCategoryOptions()); ?>
<?php echo $form->error($model, 'category'); ?>
</div>
but the data is not inserting into tbl_issue database
plz reply
thanks in advance
#2
Posted 02 November 2010 - 08:49 AM
Your function getCategoryOptions() should return an array like that:
You can create it with CListData:
You can check if $_POST['modelId']['category_id'] is corrected, if it is so it means that the attribute category_id is not safe, you have to add to the list of safe attributes.
array('primaryKey'=>'displayData')
You can create it with CListData:
<?php echo CHtml::activeDropDownList($model,'category_id', CHtml::listData(Category::model()->findAll(), 'primaryKey','optionName'));
You can check if $_POST['modelId']['category_id'] is corrected, if it is so it means that the attribute category_id is not safe, you have to add to the list of safe attributes.
#3
Posted 02 November 2010 - 09:03 AM
Adding a bit more explanation to the correct answer of Zac, I would say that in your Controllers Action you receive the post also like:
$model->attributes = $_POST['modelID'];
$model->save();
---
if it doesnt save do in your rules():
array('category_id','safe'),
---
best
$model->attributes = $_POST['modelID'];
$model->save();
---
if it doesnt save do in your rules():
array('category_id','safe'),
---
best
¿How long would it take for you to understand that you own nothing in this world?
www.ramirezcobos.com
www.ramirezcobos.com
#4
Posted 03 November 2010 - 12:27 AM
zaccaria, on 02 November 2010 - 08:49 AM, said:
Your function getCategoryOptions() should return an array like that:
You can create it with CListData:
You can check if $_POST['modelId']['category_id'] is corrected, if it is so it means that the attribute category_id is not safe, you have to add to the list of safe attributes.
array('primaryKey'=>'displayData')
You can create it with CListData:
<?php echo CHtml::activeDropDownList($model,'category_id', CHtml::listData(Category::model()->findAll(), 'primaryKey','optionName'));
You can check if $_POST['modelId']['category_id'] is corrected, if it is so it means that the attribute category_id is not safe, you have to add to the list of safe attributes.
its working
thanks for suggestion
#5
Posted 03 November 2010 - 12:27 AM
Antonio Ramirez, on 02 November 2010 - 09:03 AM, said:
Adding a bit more explanation to the correct answer of Zac, I would say that in your Controllers Action you receive the post also like:
$model->attributes = $_POST['modelID'];
$model->save();
---
if it doesnt save do in your rules():
array('category_id','safe'),
---
best
$model->attributes = $_POST['modelID'];
$model->save();
---
if it doesnt save do in your rules():
array('category_id','safe'),
---
best
its working fine
thanks for suggestion
#6
Posted 03 January 2012 - 08:55 AM
i have two model
1)Tree
2)TreeType
_form.php(tree.php)
Tree.php
the data is not inserting into tbl_tree database.
???
helf me...!
thanks for reply
1)Tree
2)TreeType
_form.php(tree.php)
echo CHtml::activeDropDownList($model,'id_typetree',$model->getTypeTree());
Tree.php
public function getTypeTree()
{
$TypeArray = CHtml::listData(Treetype::model()->findAll(array('order' => 'name')), 'id_typetree', 'name');
return $TypeArray;
}the data is not inserting into tbl_tree database.
helf me...!
thanks for reply
#7
Posted 06 January 2012 - 07:02 AM
richdad.tx, on 03 January 2012 - 08:55 AM, said:
i have two model
1)Tree
2)TreeType
_form.php(tree.php)
Tree.php
the data is not inserting into tbl_tree database.
???
helf me...!
thanks for reply
1)Tree
2)TreeType
_form.php(tree.php)
echo CHtml::activeDropDownList($model,'id_typetree',$model->getTypeTree());
Tree.php
public function getTypeTree()
{
$TypeArray = CHtml::listData(Treetype::model()->findAll(array('order' => 'name')), 'id_typetree', 'name');
return $TypeArray;
}the data is not inserting into tbl_tree database.
helf me...!
thanks for reply
hi. ok.
thanks all
#8
Posted 06 January 2012 - 07:07 AM
Er, Richdad.tx - does this mean you've got it solved? 
"Less noise - more signal"
Share this topic:
Page 1 of 1

Help
This topic is locked













