Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Angular 4 boolean form values & Phalcon

I use phalcon & angular together. I have a form in angular:

<!--rest of form-->
<label class="radio-inline" *ngFor="let m of marriageCtrl">
            <input type="radio" formControlName="marriage" [value]="m.value">{{m.label}}
</label>

value is boolean: true/false. When I submit it to form, I get values in phalcon:

public function SaveAction() 
{
    $formValues = $this->request->getJsonRawbody();
    $person = new Person();
    foreach($formValues as $key=>$val)
    {
            $person->$key = $vale;

    }
    //Rest of Person model properties
    if($person->save() == true) {
        return ["message"=>"Person saved Successfully!"];
    }else {
        $message = '';
        foreach($person->getMessages() as $msg) {
            $message = $message.$msg->getMessage() 
        }
        return ['message'=>$message];
    }
}

It is ok for other properties but for marriage which is boolean returns:

marriage is required

But if I var_dump() person object, It shows:

["marriage"]=>
  bool(true)

What db backend are you using?

Mysql and marriage column is tinyint(1)



607
Accepted
answer

It seems converting marriage column from TINYINT(1) to BIT solved problem!