Note that there are some explanatory texts on larger screens.

plurals
  1. PO$model-save() throwing foreach invalid argument error in Yii
    primarykey
    data
    text
    <p>here is my code, when i am calling this method an error occured and say "Invalid argument supplied for foreach() ". Anyone? any idea ?</p> <pre><code>$state = array( 'state_status_id' =&gt; '4', 'fax_format_preference_id' =&gt; '2', 'state_reference_code' =&gt; $state_ref-&gt;reference_code, 'leap_fqdn' =&gt; $leap_fqdn , 'description' =&gt; $state_ref-&gt;name."--".$leap_fqdn, ); $model = new States; $model-&gt;setAttributes($state, false); $model-&gt;setIsNewRecord(true); $res = $model-&gt;save(); </code></pre> <p>here is stack info:</p> <pre><code> public function createValidators(){ $validators=new CList; foreach($this-&gt;rules() as $rule) { if(isset($rule[0],$rule[1])) // attributes, validator name $validators-&gt;add(CValidator::createValidator($rule[1],$this,$rule[0],array_slice($rule,2))); else throw new CException(Yii::t('yii','{class} has an invalid validation rule. The rule must specify attributes to be validated and the validator name.', array('{class}'=&gt;get_class($this)))); } return $validators; } </code></pre> <p>this is Rule method, i don't know why this is not working while same things is working fine in other models and controllers.</p> <pre><code>public function rules() { //Rules for admins editing state information if(Roles::has_permission('update','all_states')) { return array( array('state_status_id, fax_format_preference_id, state_reference_code, leap_fqdn, description', 'required'), array('state_status_id, fax_format_preference_id', 'length', 'max'=&gt;10), array('leap_fqdn', 'length', 'max'=&gt;128), array('description', 'length', 'max'=&gt;255), array('updated_at,default_user_role', 'safe'), // Please remove those attributes that should not be searched. array(' state_status_id, fax_format_preference_id, created_at, updated_at, state_reference_code, leap_fqdn, description', 'safe', 'on'=&gt;'search'), ); } if(Roles::has_permission('update','state_state')) { return array( array('fax_format_preference_id', 'required'), array('fax_format_preference_id', 'length', 'max'=&gt;10), array('updated_at', 'safe'), ); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload