I dont have such a line in my controller.
mb_strlen(array("9","10"),"UTF-8");
i was just telling about my error when i try executing it.
I dont have such a line in my controller.
mb_strlen(array("9","10"),"UTF-8");
i was just telling about my error when i try executing it.
What is the function that gives you the error?
Are you sure that the beforeSave succeded and converted the array to a string before calling this function?
Are you sure that you have not some stuff like length validator on the field?
Try douing a bit of debug, and understand what is calling mb_strlen on this array.
Everything started working but now problem is storing it in db
I am getting the value like this inside db
why so??
Inside model i have given in rules for skillid field like dis
array('mobilenumber,companyname,name,email,factorylocation,skillid','required')
i hope that is not the prob
You save the data serialized
http://php.net/manual/en/function.serialize.php
following Zaccaria’s instructions
//serialize the data before save to database
public function beforeSave()
{
$this->skillid= serialize($this->skillid);
return parent::beforeSave();
}
//transform the serialized data back into its normal form after find
public function afterFind()
{
$this->skillid= unserialize($this->skillid);
return parent::afterFind();
}
By following his words only it was possible to do…
But why is the data getting stored like that??
is it the way it gets stored while using serialization?
Anyway i have started using json_encodeinstead of serialization…
If you want to store a string like "9,10" you can use the PHP function implode() and explode()…
i am trying on implode now…
public function beforeSave()
{
$this->skillid= implode (',',$this->skillid);
return parent::beforeSave();
}
but giving a error implode() [<a href=‘function.implode’>function.implode</a>]: Invalid arguments passed
Even though this error is shown all my data is getting stored properly in db…
Can someone help me out… why is this error coming??
Guys i fixed it with a crooked way… i just removed the error msg from the code…
What do you mean by that?
What line(s) did you remove from what source file?
i just removed a single line from my order form
<?php echo $form->error($model,'skillid'); ?>
So no error will be coming…
Actual Problem Now
It gives you an error when ‘skillid’ is empty, therefore you should use @ or test the variable, like
if(!empty($this->skillid))
$this->skillid=implode(',',$this->skillid);
and after do that, continue using the error field
Great… Thank you… It’s working…