php - laravel form helper htmlentities error -


i'm using laravel 5.1 , struggling resolve problem handling old form data retrieved using 'form::old()'

my form field names arrays. when form submitted if there's validation issue user redirected expected , aiming retrieve values submitted re-populate form. in case values returned in array.

however standard form helper unable handle arrays. returns error:

htmlentities() expects parameter 1 string, array given  

so decided try , intercept error , create own helper function capture array, retrieve correct value , pass create form element.

here's helper function:

public function arrayhidden($name, $value = null, $options = array()) {     if(isset($options) && array_key_exists('key', $options) && is_array($value)) {         $value = $value[$options['key']];     }     return $this->input('hidden', $name, $value, $options); } 

here's how i'm using in page:

form::arrayhidden('id[]', form::old('id', $fixture->id), ['key'=>$key]) 

$key index created in foreach loop

doing var_dump of returned $value it's noted string error still occurs.

this baffling - though i've substituted array qith correct value array still appears in method.

any ideas on how avoid array error?

thank

form::arrayhidden('id[]', form::old('id', $fixture->id), ['key'=>$key]) must returning array.

you must using in view somewhere:

{{ form::arrayhidden('id[]', form::old('id', $fixture->id), ['key'=>$key]) }} 

everything inside {{ }} must string - hence error.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -