<p>เรื่องมีอยู่ว่า ผมได้แก้โคด _form.php ของ research ซึ่งเดิมเป็น textfield จะเปลี่ยนให้เป็น dropDownlist ที่ดึงข้อมูลจาก ตาราง researcher </p><p>ซึ่งเมื่อแก้จาก textfield เป็น dropDownlist เกิด error ขึ้น**</p><p>โคดที่ผมใช้ครับ</p><p><div></p><p><?php echo $form->labelEx($model,'idresearcher'); ?></p><p><?php echo $form->textField($model,'idresearcher'); ?></p><p><?php echo $form->error($model,'idresearcher'); ?></p><p><span style="background-color: initial;"></div></span> </p><p>ไม่ทราบว่ากรณีอย่างนี้เกิดเพราะอะไรครับ</p><p>** ---------------------error --------------------</p><h1>CException</h1><p>Property "Research.researcher" is not defined.</p><p>/home/rdkkc/public_html/framework/db/ar/CActiveRecord.php(145)</p><pre>133 */ 134 public function __get($name) 135 { 136 if(isset($this->_attributes[$name])) 137 return $this->_attributes[$name]; 138 elseif(isset($this->getMetaData()->columns[$name])) 139 return null; 140 elseif(isset($this->_related[$name])) 141 return $this->_related[$name]; 142 elseif(isset($this->getMetaData()->relations[$name])) 143 return $this->getRelated($name); 144 else 145 return parent::__get($name); 146 } 147 148 /** 149 * PHP setter magic method. 150 * This method is overridden so that AR attributes can be accessed like properties. 151 * @param string $name property name 152 * @param mixed $value property value 153 */ 154 public function __set($name,$value) 155 { 156 if($this->setAttribute($name,$value)===false) 157 { </pre><h2>Stack Trace</h2><table><tbody><tr><td>#0</td><td><p>+ /home/rdkkc/public_html/framework/db/ar/CActiveRecord.php(145): <strong>CComponent</strong>-><strong>__get</strong>("researcher") </p></td></tr><tr> <td>#1</td> <td> <p>+</p> /home/rdkkc/public_html/framework/web/helpers/CHtml.php(2728): <strong>CActiveRecord</strong>-><strong>__get</strong>("researcher") </td></tr><tr> <td>#2</td> <td> <p>+</p> /home/rdkkc/public_html/framework/web/helpers/CHtml.php(1981): <strong>CHtml</strong>::<strong>resolveValue</strong>(Research, "researcher") </td></tr><tr> <td>#3</td> <td> <p>+</p> /home/rdkkc/public_html/framework/web/widgets/CActiveForm.php(914): <strong>CHtml</strong>::<strong>activeDropDownList</strong>(Research, "researcher", array("" => "พลนิกรณ์"), array("empty" => "เลือกการแสดงผล")) </td></tr><tr> <td>#4</td> <td> <p>–</p> /home/rdkkc/public_html/protected/views/research/_form.php(56): <strong>CActiveForm</strong>-><strong>dropDownList</strong>(Research, "researcher", array("" => "พลนิกรณ์"), array("empty" => "เลือกการแสดงผล"))<pre>51 52 <div> 53 <?php echo $form->labelEx($model,'researcher'); ?> 54 <?php echo $form->dropDownList($model,'researcher', 55 CHtml::listData(Researcher::model()->findAll(),'id','name'), 56 array('empty' => 'เลือกการแสดงผล'));?> 57 58 <?php echo $form->error($model,'researcher'); ?> 59 </div> 60 61 <div> </pre> </td></tr><tr><td>#5</td><td><p>+ /home/rdkkc/public_html/framework/web/CBaseController.php(126): <strong>require</strong>("/home/rdkkc/public_html/protected/views/research/_form.php")</p></td></tr><tr><td>#6</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CBaseController.php(95): <strong>CBaseController</strong>-><strong>renderInternal</strong>("/home/rdkkc/public_html/protected/views/research/_form.php", array("model" => Research), true) </p></td></tr><tr><td>#7</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CController.php(869): <strong>CBaseController</strong>-><strong>renderFile</strong>("/home/rdkkc/public_html/protected/views/research/_form.php", array("model" => Research), true) </p></td></tr><tr><td>#8</td><td><p>–</p> /home/rdkkc/public_html/protected/views/research/create.php(18): <strong>CController</strong>-><strong>renderPartial</strong>("_form", array("model" => Research))<pre>13 ); 14 ?> 15 16 <h1>Create Research</h1> 17 18 <?php $this->renderPartial('_form', array('model'=>$model)); ?></pre> </td></tr><tr><td>#9</td><td><p>+ /home/rdkkc/public_html/framework/web/CBaseController.php(126): <strong>require</strong>("/home/rdkkc/public_html/protected/views/research/create.php")</p></td></tr><tr><td>#10</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CBaseController.php(95): <strong>CBaseController</strong>-><strong>renderInternal</strong>("/home/rdkkc/public_html/protected/views/research/create.php", array("model" => Research), true) </p></td></tr><tr><td>#11</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CController.php(869): <strong>CBaseController</strong>-><strong>renderFile</strong>("/home/rdkkc/public_html/protected/views/research/create.php", array("model" => Research), true) </p></td></tr><tr><td>#12</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CController.php(782): <strong>CController</strong>-><strong>renderPartial</strong>("create", array("model" => Research), true) </p></td></tr><tr><td>#13</td><td><p>–</p> /home/rdkkc/public_html/protected/controllers/ResearchController.php(79): <strong>CController</strong>-><strong>render</strong>("create", array("model" => Research))<pre>74 $this->redirect(array('view','id'=>$model->idResearch)); 75 } 76 77 $this->render('create',array( 78 'model'=>$model, 79 )); 80 } 81 82 /** 83 * Updates a particular model. 84 * If update is successful, the browser will be redirected to the 'view' page. </pre> </td></tr><tr><td>#14</td><td><p>+ /home/rdkkc/public_html/framework/web/actions/CInlineAction.php(49): <strong>ResearchController</strong>-><strong>actionCreate</strong>()</p></td></tr><tr><td>#15</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CController.php(308): <strong>CInlineAction</strong>-><strong>runWithParams</strong>(array("r" => "research/create")) </p></td></tr><tr><td>#16</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/filters/CFilterChain.php(133): <strong>CController</strong>-><strong>runAction</strong>(CInlineAction) </p></td></tr><tr><td>#17</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/filters/CFilter.php(40): <strong>CFilterChain</strong>-><strong>run</strong>() </p></td></tr><tr><td>#18</td><td><p>–</p> /home/rdkkc/public_html/framework/web/CController.php(1145): <strong>CFilter</strong>-><strong>filter</strong>(CFilterChain)<pre>1140 */ 1141 public function filterAccessControl($filterChain) 1142 { 1143 $filter=new CAccessControlFilter; 1144 $filter->setRules($this->accessRules()); 1145 $filter->filter($filterChain); 1146 } 1147 1148 /** 1149 * Returns a persistent page state value. 1150 * A page state is a variable that is persistent across POST requests of the same page. </pre> </td></tr><tr><td>#19</td><td><p>+ /home/rdkkc/public_html/framework/web/filters/CInlineFilter.php(58): <strong>CController</strong>-><strong>filterAccessControl</strong>(CFilterChain)</p></td></tr><tr><td>#20</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/filters/CFilterChain.php(130): <strong>CInlineFilter</strong>-><strong>filter</strong>(CFilterChain) </p></td></tr><tr><td>#21</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CController.php(291): <strong>CFilterChain</strong>-><strong>run</strong>() </p></td></tr><tr><td>#22</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CController.php(265): <strong>CController</strong>-><strong>runActionWithFilters</strong>(CInlineAction, array("accessControl", "postOnly + delete")) </p></td></tr><tr><td>#23</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CWebApplication.php(282): <strong>CController</strong>-><strong>run</strong>("create") </p></td></tr><tr><td>#24</td><td><p>+</p><p> /home/rdkkc/public_html/framework/web/CWebApplication.php(141): <strong>CWebApplication</strong>-><strong>runController</strong>("research/create") </p></td></tr><tr><td>#25</td><td><p>+</p><p> /home/rdkkc/public_html/framework/base/CApplication.php(184): <strong>CWebApplication</strong>-><strong>processRequest</strong>() </p></td></tr><tr><td>#26</td><td><p>+</p><p> /home/rdkkc/public_html/index.php(13): <strong>CApplication</strong>-><strong>run</strong>() </p></td></tr></tbody></table><p>2015-08-07 21:52:26 Apache/2.4.10 (Debian) <a href="http://www.yiiframework.com/">Yii Framework</a>/1.1.16</p>
เรื่องมีอยู่ว่า ผมได้แก้โคด _form.php ของ research ซึ่งเดิมเป็น textfield จะเปลี่ยนให้เป็น dropDownlist ที่ดึงข้อมูลจาก ตาราง researcher
ซึ่งเมื่อแก้จาก textfield เป็น dropDownlist เกิด error ขึ้น**
โคดที่ผมใช้ครับ
<div>
<?php echo $form->labelEx($model,'idresearcher'); ?>
<?php echo $form->textField($model,'idresearcher'); ?>
<?php echo $form->error($model,'idresearcher'); ?>
</div>
ไม่ทราบว่ากรณีอย่างนี้เกิดเพราะอะไรครับ
** ---------------------error --------------------
Property "Research.researcher" is not defined.
/home/rdkkc/public_html/framework/db/ar/CActiveRecord.php(145)
133 */ 134 public function __get($name) 135 { 136 if(isset($this->_attributes[$name])) 137 return $this->_attributes[$name]; 138 elseif(isset($this->getMetaData()->columns[$name])) 139 return null; 140 elseif(isset($this->_related[$name])) 141 return $this->_related[$name]; 142 elseif(isset($this->getMetaData()->relations[$name])) 143 return $this->getRelated($name); 144 else 145 return parent::__get($name); 146 } 147 148 /** 149 * PHP setter magic method. 150 * This method is overridden so that AR attributes can be accessed like properties. 151 * @param string $name property name 152 * @param mixed $value property value 153 */ 154 public function __set($name,$value) 155 { 156 if($this->setAttribute($name,$value)===false) 157 {
#0 | + /home/rdkkc/public_html/framework/db/ar/CActiveRecord.php(145): CComponent->__get("researcher") |
#1 |
+ /home/rdkkc/public_html/framework/web/helpers/CHtml.php(2728): CActiveRecord->__get("researcher") |
#2 |
+ /home/rdkkc/public_html/framework/web/helpers/CHtml.php(1981): CHtml::resolveValue(Research, "researcher") |
#3 |
+ /home/rdkkc/public_html/framework/web/widgets/CActiveForm.php(914): CHtml::activeDropDownList(Research, "researcher", array("" => "พลนิกรณ์"), array("empty" => "เลือกการแสดงผล")) |
#4 |
– /home/rdkkc/public_html/protected/views/research/_form.php(56): CActiveForm->dropDownList(Research, "researcher", array("" => "พลนิกรณ์"), array("empty" => "เลือกการแสดงผล"))51 52 <div> 53 <?php echo $form->labelEx($model,'researcher'); ?> 54 <?php echo $form->dropDownList($model,'researcher', 55 CHtml::listData(Researcher::model()->findAll(),'id','name'), 56 array('empty' => 'เลือกการแสดงผล'));?> 57 58 <?php echo $form->error($model,'researcher'); ?> 59 </div> 60 61 <div> |
#5 | + /home/rdkkc/public_html/framework/web/CBaseController.php(126): require("/home/rdkkc/public_html/protected/views/research/_form.php") |
#6 | + /home/rdkkc/public_html/framework/web/CBaseController.php(95): CBaseController->renderInternal("/home/rdkkc/public_html/protected/views/research/_form.php", array("model" => Research), true) |
#7 | + /home/rdkkc/public_html/framework/web/CController.php(869): CBaseController->renderFile("/home/rdkkc/public_html/protected/views/research/_form.php", array("model" => Research), true) |
#8 | – /home/rdkkc/public_html/protected/views/research/create.php(18): CController->renderPartial("_form", array("model" => Research))13 ); 14 ?> 15 16 <h1>Create Research</h1> 17 18 <?php $this->renderPartial('_form', array('model'=>$model)); ?> |
#9 | + /home/rdkkc/public_html/framework/web/CBaseController.php(126): require("/home/rdkkc/public_html/protected/views/research/create.php") |
#10 | + /home/rdkkc/public_html/framework/web/CBaseController.php(95): CBaseController->renderInternal("/home/rdkkc/public_html/protected/views/research/create.php", array("model" => Research), true) |
#11 | + /home/rdkkc/public_html/framework/web/CController.php(869): CBaseController->renderFile("/home/rdkkc/public_html/protected/views/research/create.php", array("model" => Research), true) |
#12 | + /home/rdkkc/public_html/framework/web/CController.php(782): CController->renderPartial("create", array("model" => Research), true) |
#13 | – /home/rdkkc/public_html/protected/controllers/ResearchController.php(79): CController->render("create", array("model" => Research))74 $this->redirect(array('view','id'=>$model->idResearch)); 75 } 76 77 $this->render('create',array( 78 'model'=>$model, 79 )); 80 } 81 82 /** 83 * Updates a particular model. 84 * If update is successful, the browser will be redirected to the 'view' page. |
#14 | + /home/rdkkc/public_html/framework/web/actions/CInlineAction.php(49): ResearchController->actionCreate() |
#15 | + /home/rdkkc/public_html/framework/web/CController.php(308): CInlineAction->runWithParams(array("r" => "research/create")) |
#16 | + /home/rdkkc/public_html/framework/web/filters/CFilterChain.php(133): CController->runAction(CInlineAction) |
#17 | + /home/rdkkc/public_html/framework/web/filters/CFilter.php(40): CFilterChain->run() |
#18 | – /home/rdkkc/public_html/framework/web/CController.php(1145): CFilter->filter(CFilterChain)1140 */ 1141 public function filterAccessControl($filterChain) 1142 { 1143 $filter=new CAccessControlFilter; 1144 $filter->setRules($this->accessRules()); 1145 $filter->filter($filterChain); 1146 } 1147 1148 /** 1149 * Returns a persistent page state value. 1150 * A page state is a variable that is persistent across POST requests of the same page. |
#19 | + /home/rdkkc/public_html/framework/web/filters/CInlineFilter.php(58): CController->filterAccessControl(CFilterChain) |
#20 | + /home/rdkkc/public_html/framework/web/filters/CFilterChain.php(130): CInlineFilter->filter(CFilterChain) |
#21 | + /home/rdkkc/public_html/framework/web/CController.php(291): CFilterChain->run() |
#22 | + /home/rdkkc/public_html/framework/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array("accessControl", "postOnly + delete")) |
#23 | + /home/rdkkc/public_html/framework/web/CWebApplication.php(282): CController->run("create") |
#24 | + /home/rdkkc/public_html/framework/web/CWebApplication.php(141): CWebApplication->runController("research/create") |
#25 | + /home/rdkkc/public_html/framework/base/CApplication.php(184): CWebApplication->processRequest() |
#26 | + /home/rdkkc/public_html/index.php(13): CApplication->run() |
2015-08-07 21:52:26 Apache/2.4.10 (Debian) Yii Framework/1.1.16
ตอบ/อธิบาย