I am trying to make a search form at my companies action so I set this but even if I write something at the text field the validation does not pass what is wrong?
[edit] I use the Scenario companies, the named Scenarios use also the generic validation rules?If this how can I separate this Scenario?[/edit]
class Companies extends CActiveRecord {....
public function rules() {
return array(
array('cmp_name','required', 'on'=>'companies'),.....
.....
public function safeAttributes() {
return array(
parent::safeAttributes(),.......
'companies'=>"cmp_name"
);
...
public function actionCompanies() {
$this->processAdminCommand();
$criteria=new CDbCriteria;
$company=new Companies;
if (isset($_POST['Companies'])) {
$company->setScenario('companies');
$company->attributes=$_POST['Companies'];
print_r ($_POST['Companies']);
if ($company->validate())
{ $criteria->condition='cmp_name like :postID';
$criteria->params=array(':postID'=>"%". $company->cmp_name."%");
print_r ($_POST['Companies']);
}
else die();
}....