Form_helper#281
Form_helper#281Portaflex wants to merge 4 commits intocodeigniter4:developfrom Portaflex:Form_helper
Conversation
|
There is one issue with this helper: For the HTML5 output element we would need a class instead of a helper. This is the code to be generated: `
|
lonnieezell
left a comment
There was a problem hiding this comment.
FYI - There's no need to delete a PR and submit a new one. You lose discussion history when you do that. Just add new commits to the branch and it will show up in the same PR.
This is still missing the HTML inputs I asked for last time, like email, number, date, etc.
Also, you need to provide tests for all of the fields. It looks like you brought over the existing tests from CI3, but then never added any more.
system/Helpers/form_helper.php
Outdated
| * @param mixed | ||
| * @return string | ||
| */ | ||
| function _attributes_to_string($attributes): string |
There was a problem hiding this comment.
I believe we can remove this method and use the stringify_attributes that is in the Common file....
Please double-check, but at a glance, they appear the same.
| @@ -0,0 +1,201 @@ | |||
| <?php namespace CodeIgniter\Helpers; | |||
|
|
|||
| class FormHelperTest extends \CIUnitTestCase | |||
There was a problem hiding this comment.
The filename is incorrect here. You have FormHelperText, instead of FormHelperTest. Did you run this locally before providing a PR?
There was a problem hiding this comment.
Yeah, name changed and local test passed. ;-) I'll try to add some more test.
system/Helpers/form_helper.php
Outdated
|
|
||
| // ------------------------------------------------------------------------ | ||
|
|
||
| if ( ! function_exists('_parse_form_attributes')) |
There was a problem hiding this comment.
Please remove the CI3 style naming where functions start with underscores.
system/Helpers/form_helper.php
Outdated
| { | ||
| $value = $_POST[$field] ?? $default; | ||
|
|
||
| return ($html_escape) ? html_escape($value) : $value; |
There was a problem hiding this comment.
No function named html_escape exists in the framework. You should be using the esc() method instead. Which will also require you ensure it's loaded....
|
|
||
| if ( ! function_exists('form_output')) | ||
| { | ||
| function form_output() |
There was a problem hiding this comment.
This should be possible as a simple field. While other fields need to be attached to it, usually through JS, the output field itself seems to be a standalone field if I understand this one correctly.
There was a problem hiding this comment.
No, no. It's not a standalone field. Look at the code:
`
0 100 + =
`
You have to declare the oninput html event in the form opening label. So, you need to have the oninput operation set before calling form_open().
There was a problem hiding this comment.
alright, let's simplify then and scrap this one also. Not sure how often people actually use it anyway...
There was a problem hiding this comment.
Right. I would say nobody uses it.
system/Helpers/form_helper.php
Outdated
|
|
||
| if ( ! function_exists('form_keygen')) | ||
| { | ||
| function form_keygen() |
There was a problem hiding this comment.
This element doesn't seem to be used by any browsers at the moment, so scrap this method.
There was a problem hiding this comment.
BTW I closed one PR and opened a new one because some files from other branches "slided" into this one. I didn't know how to remove them. :-(
There was a problem hiding this comment.
Makes sense. No worries, just trying to keep things orderly where possible. :)
|
We have this: HTML5 input types: HTML5 input attributes: And almost all of them can be passed as attributes to form_input() as $data or $extra. A few attributes don't go as a key = value pair, e.g. "disabled" and "readonly". So which of them are we gonna put in?. |
Ideally all of the input types should be included. Another option, and a simpler and more future-proof version, would be to adjust the As for the attributes, allow them all. No sense restricting. I'm not sure if it would be best to do special checks here, or modify |
|
Updated and merged in #298 |
Form helper revisited.