AsgardCms / Platform

A modular multilingual CMS built with Laravel 5.
https://asgardcms.com/
MIT License
779 stars 240 forks source link

2depth array access of Form::normalInput #548

Open darron1217 opened 6 years ago

darron1217 commented 6 years ago

Summary of issue

Recently I'm utilizing json type column a lot This made me to use input name like this <input name="options[birthday]" />

AsgardCMS's input macro is simple, and working well with saving data. But retrieving is not working with this situation Form::normalInput('options[birthday]', 'Birthday', $errors, $object)

Steps to reproduce

  1. Create model with array-casted attribute (json type column on db)
  2. Use Form::normalInput on view
  3. Save Data and check if it's saved well on db
  4. Refresh page and see empty input field

System Details

darron1217 commented 6 years ago

How about implementing it using explode()?

$name = 'options[birthday][test]';
$name = str_replace(']', '', $name);
$vars = explode('[', $name);

print_r($vars);
// Array
// (
//    [0] => options
//    [1] => birthday
//    [2] => test
// )