Yii Framework Forum: Useing Attribute Which Is Not In Db Table - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Useing Attribute Which Is Not In Db Table Rate Topic: -----

#1 User is offline   Sujoy Bhowmick 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 27-December 12

Posted 19 January 2013 - 08:28 AM

Hi

Actually i have a search form in view and want to filter my list of data according to value provided by the search form.That's why i need to get the value and set it as model attribute so that i can filter my select query in model with this attribute. I declared the attribute as safe in the current scenario.also write something like

in controller
$model->search_value = 'some value'

in model
array('search_value', 'safe', 'on'=>'search')

in view
<div class="sidebar_search">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'search-form',
'enableAjaxValidation'=>false,
'action'=>Yii::app()->createUrl('Category/index'),
)); ?>
<?php echo $form->textField($model,'search_value',array('class'=>'search_input','onclick'=>'this.value=""')); ?>
<input type="image" class="search_submit" src="<?php echo Yii::app()->request->baseUrl;?>/css/admin/images/search.png" />
<?php $this->endWidget(); ?>
</div>

but it is showing error that "Property "Category.search_value" is not defined."

i know that there is some problem but can't figure out what.i also don't know even i can use it like that or not.But i need the following flow
1.get input value from view in controller action.
2.send this value to model so that i can use it to filter the result according to it.

please suggest what should i do when i am using AR.
0

#2 User is offline   rootbear 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 204
  • Joined: 17-June 11

Posted 19 January 2013 - 08:34 AM

in your model, do you have?

public $search_value; 

when i ask, if my question does not make sense, don't blame on me, coz i am new here to learn yii;
when i answer, if my answer does not make sense, don't blame on me, coz i am trying to answer to be answered;

ok, i'm covered to mess up and fooling around, yeehaw ...
0

#3 User is offline   Sujoy Bhowmick 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 27-December 12

Posted 19 January 2013 - 12:40 PM

View Postrootbear, on 19 January 2013 - 08:34 AM, said:

in your model, do you have?

public $search_value; 



thanks for your reply i just missed that thing.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users