adminarchitect / core

AdminArchitect - Active Admin for Laravel
http://adminarchitect.com
MIT License
211 stars 66 forks source link

Multicheckbox and Multiselect #12

Closed YulKard closed 6 years ago

YulKard commented 6 years ago

Good day! In my project I use a multicheckbox field. In the form I update the field http://joxi.ru/krDDZDZSEVgnzr : `public function form() { return $this->scaffoldForm() ->update("type_discharge", function (FormElement $element) { $control = new MultiCheckbox("type_discharge"); $control->setOptions($this->config()["type_discharge"]); return $element->setInput($control); });

}``` But when I save the data, an error occurs: http://joxi.ru/J2blMlMuXnga5r In the Saver.php exist the method handleJsonType. There is a method in which the type of the form field is checked and the array obtained in this case or the Json is decoded. That is, we get an array, and there must be a string (json_decode accepts only a JSON string). For the experiment, I comment this line and data is successfully saved in the database. In the class Multichecbox method htmlInput() made for: return Form::checkbox($name, $value, in_array($value, (array) json_decode($this->value)), $attributes);` Tell me, please, how it should be correct. Maybe I misunderstood something. Thank you in advance.