Closed meshmmanuel closed 4 years ago
I wanted to populate the metadata input dynamically with more than one data using ajax and input id. I noticed the input below would be easier to accept multiple input.
<input type="hidden" id="meta..." name="custom_metadata[key]" value="value">
instead of this:
<input type="hidden" name="metadata" value="{{ json_encode($array = ['key_name' => 'value',]) }}" >
For example:
<input type="hidden" id="meta..." name="custom_metadata[key1]" value="value1"> <input type="hidden" id="meta..." name="custom_metadata[key2]" value="value2">
Would be passed to PHP as: array:2 [▼ "key1" => "value1" "key2" => "value2" ]
and when encoded as json, would be: "{"key1":"value1","key2":"value2"}"
achieving the same thing.
I wanted to populate the metadata input dynamically with more than one data using ajax and input id. I noticed the input below would be easier to accept multiple input.
<input type="hidden" id="meta..." name="custom_metadata[key]" value="value">
instead of this:
<input type="hidden" name="metadata" value="{{ json_encode($array = ['key_name' => 'value',]) }}" >
For example:
Would be passed to PHP as: array:2 [▼ "key1" => "value1" "key2" => "value2" ]
and when encoded as json, would be: "{"key1":"value1","key2":"value2"}"
achieving the same thing.