#feature supporting the standard PHP convention in parsing array-style name-values in input fields from HTML
See original GitHub issueIn follow up to https://github.com/node-formidable/formidable/issues/33#issuecomment-579611738:
@lmj0011 & others.
Please try
npm install formidable@canary
- preview of v2. The API is almost the same, check the docs or open new issue if there’s some problem.…
@tunnckoCore this is really not working as expected.
Output
_method: 'PATCH',
title: 'A whole new title!',
slug: 'a-whole-new-title',
content: 'undefined',
"timestamp[]['amend']": 'Fri Sep 14 2018 00:00:00 GMT+0200 (Central European Summer Time)',
"timestamp[]['publish']": 'Fri Sep 15 2018 00:00:00 GMT+0200 (Central European Summer Time)',
'timestamps[][amend]': ''
also when the names don’t have the extra []
they are still not processed as an array/object!
Code
const form = formidable({ multiples: true });
form.parse(this.req, (err, fields, files) => {
if (err) {
next(err);
return;
}
console.log(fields)
});
Background
output from npm list
:
├─┬ formidable@2.0.0-canary.20200402.2
│ ├─┬ dezalgo@1.0.3
│ │ ├── asap@2.0.6
│ │ └── wrappy@1.0.2
│ ├── hexoid@1.0.0
│ └─┬ once@1.4.0
│ └── wrappy@1.0.2 deduped
HTML form
The desired form to be processed as an array/object based on PHP convention (documentation):
<header>Dates</header>
<div class="c-card__item pure-control-group">
<div class="os-form-group">
<label>Draft: </label>
<input class="flatpickr form-control" name="timestamp[amend]" type="text"
value="<%= book.related('timestamp').get('draft') %>">
</div>
<div class="os-form-group">
<label>Publish: </label>
<input class="flatpickr form-control" name="timestamp[publish]" type="text"
value="<%= book.related('timestamp').get('publish') %>">
</div>
<div class="os-form-group">
<label>Amend: </label>
<input class="flatpickr form-control" name="timestamp[amend]" type="text"
value="<%= book.related('timestamp').get('amend') %>">
</div>
</div>
Desired output
timestamp {
draft: 'xyy',
publish: 'xyz',
amend: 'xyz',
}
PS. Thanks in advance & sorry if I’m missing some beginner configuration option!
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
javascript - HTML Array Fields Parsing in PHP
I am using Laravel 5.2. I have the following jQuery to allow the user to add more invoice items: $("#add_invoice_item").click(function ...
Read more >Pro PHP
Part 3, The Standard PHP Library (SPL): The SPL contains some of the most advanced PHP code ever written. It offers language support...
Read more >Object-Oriented Programming with PHP5
Chapter 5 focuses on two very important features of object-oriented programming in PHP, reflection and unit testing. PHP5 replaces many old APIs with ......
Read more >Beginning Linux® Programming 4th Edition
supports quite a lot of features from other systems, ... One special way of passing input to a command from a shell script...
Read more >https://www.drupal.org/files/twig-1898466-60.patch
+ * - 302: Found (default in Drupal and PHP, sometimes used for spamming search + ... @defgroup forms Form builder functions @@...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks for the guidance!
Published
formidable@2.0.0-canary.20200504.1
, which includes couple of other things since last published canary.