View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0022310 | mantisbt | html | public | 2017-02-03 12:38 | 2020-02-10 10:28 |
Reporter | j_schultz | Assigned To | community | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 2.1.0 | ||||
Target Version | 2.7.0 | Fixed in Version | 2.7.0 | ||
Summary | 0022310: Use HTML5 "required" attribute for required form fields | ||||
Description | When submitting a bug, there are several form fields that mustn't be left empty, usually marked with an asterisk. | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
related to | 0021694 | assigned | syncguru | inconsistent presentation of required fields |
related to | 0023507 | closed | dregad | Users can't change their password when it is blank |
related to | 0023512 | closed | atrol | Custom field type checkbox with required status, force to check all checkboxes to proceed |
related to | 0024097 | closed | atrol | Account page required change password on any field modification |
related to | 0026686 | closed | dregad | Make category on bug_report_page a required field when $g_allow_no_category = OFF; |
related to | 0026687 | closed | dregad | Required fields when reporting an issue, should also be when updating it |
Here's a proposed patch to address this problem. required-form-attributes.patch (21,079 bytes)
Index: account_page.php =================================================================== --- account_page.php (revision 13708) +++ account_page.php (working copy) @@ -187,7 +187,7 @@ <span class="required"><?php if( $t_force_pw_reset ) { ?> * <?php } ?></span> <?php echo lang_get( 'current_password' ) ?> </td> <td> - <input class="input-sm" id="password-current" type="password" name="password_current" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" /> + <input class="input-sm" id="password-current" type="password" name="password_current" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" required /> </td> </tr> <?php @@ -197,7 +197,7 @@ <span class="required"><?php if( $t_force_pw_reset ) { ?> * <?php } ?></span> <?php echo lang_get( 'new_password' ) ?> </td> <td> - <input class="input-sm" id="password" type="password" name="password" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" /> + <input class="input-sm" id="password" type="password" name="password" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" required /> </td> </tr> <tr> @@ -205,7 +205,7 @@ <span class="required"><?php if( $t_force_pw_reset ) { ?> * <?php } ?></span> <?php echo lang_get( 'confirm_password' ) ?> </td> <td> - <input class="input-sm" id="password-confirm" type="password" name="password_confirm" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" /> + <input class="input-sm" id="password-confirm" type="password" name="password_confirm" size="32" maxlength="<?php echo auth_get_password_max_size(); ?>" required /> </td> </tr> <?php Index: account_prof_edit_page.php =================================================================== --- account_prof_edit_page.php (revision 13708) +++ account_prof_edit_page.php (working copy) @@ -102,7 +102,7 @@ <span class="required">*</span><?php echo lang_get( 'platform' ) ?> </th> <td width="75%"> - <input type="text" name="platform" class="input-sm" size="32" maxlength="32" value="<?php echo string_attribute( $v_platform ) ?>" /> + <input type="text" name="platform" class="input-sm" size="32" maxlength="32" value="<?php echo string_attribute( $v_platform ) ?>" required /> </td> </tr> <tr> @@ -110,7 +110,7 @@ <span class="required">*</span><?php echo lang_get( 'os' ) ?> </th> <td> - <input type="text" name="os" class="input-sm" size="32" maxlength="32" value="<?php echo string_attribute( $v_os ) ?>" /> + <input type="text" name="os" class="input-sm" size="32" maxlength="32" value="<?php echo string_attribute( $v_os ) ?>" required /> </td> </tr> <tr> @@ -118,7 +118,7 @@ <span class="required">*</span><?php echo lang_get( 'os_version' ) ?> </th> <td> - <input type="text" name="os_build" class="input-sm" size="16" maxlength="16" value="<?php echo string_attribute( $v_os_build ) ?>" /> + <input type="text" name="os_build" class="input-sm" size="16" maxlength="16" value="<?php echo string_attribute( $v_os_build ) ?>" required /> </td> </tr> <tr> Index: account_prof_menu_page.php =================================================================== --- account_prof_menu_page.php (revision 13708) +++ account_prof_menu_page.php (working copy) @@ -114,7 +114,7 @@ <span class="required">*</span> <?php echo lang_get( 'platform' ) ?> </td> <td> - <input id="platform" type="text" name="platform" class="input-sm" size="32" maxlength="32" /> + <input id="platform" type="text" name="platform" class="input-sm" size="32" maxlength="32" required /> </td> </tr> <tr> @@ -122,7 +122,7 @@ <span class="required">*</span> <?php echo lang_get( 'os' ) ?> </td> <td> - <input id="os" type="text" name="os" class="input-sm" size="32" maxlength="32" /> + <input id="os" type="text" name="os" class="input-sm" size="32" maxlength="32" required /> </td> </tr> <tr> @@ -130,7 +130,7 @@ <span class="required">*</span> <?php echo lang_get( 'os_version' ) ?> </td> <td> - <input id="os-version" type="text" name="os_build" class="input-sm" size="16" maxlength="16" /> + <input id="os-version" type="text" name="os_build" class="input-sm" size="16" maxlength="16" required /> </td> </tr> <tr> Index: bug_change_status_page.php =================================================================== --- bug_change_status_page.php (revision 13708) +++ bug_change_status_page.php (working copy) @@ -291,7 +291,7 @@ <td> <?php if( $t_has_write_access ) { - print_custom_field_input( $t_def, $f_bug_id ); + print_custom_field_input( $t_def, $f_bug_id, $t_require ); } elseif( custom_field_has_read_access( $t_id, $f_bug_id ) ) { print_custom_field_value( $t_def, $t_id, $f_bug_id ); } Index: bug_report_page.php =================================================================== --- bug_report_page.php (revision 13708) +++ bug_report_page.php (working copy) @@ -542,7 +542,7 @@ <span class="required">*</span><label for="summary"><?php print_documentation_link( 'summary' ) ?></label> </th> <td> - <input <?php echo helper_get_tab_index() ?> type="text" id="summary" name="summary" size="105" maxlength="128" value="<?php echo string_attribute( $f_summary ) ?>" /> + <input <?php echo helper_get_tab_index() ?> type="text" id="summary" name="summary" size="105" maxlength="128" value="<?php echo string_attribute( $f_summary ) ?>" required /> </td> </tr> <tr> @@ -550,7 +550,7 @@ <span class="required">*</span><label for="description"><?php print_documentation_link( 'description' ) ?></label> </th> <td> - <textarea class="form-control" <?php echo helper_get_tab_index() ?> id="description" name="description" cols="80" rows="10"><?php echo string_textarea( $f_description ) ?></textarea> + <textarea class="form-control" <?php echo helper_get_tab_index() ?> id="description" name="description" cols="80" rows="10" required><?php echo string_textarea( $f_description ) ?></textarea> </td> </tr> @@ -613,7 +613,7 @@ <?php } else { echo string_display( lang_get_defaulted( $t_def['name'] ) ); } ?> </th> <td> - <?php print_custom_field_input( $t_def, ( $f_master_bug_id === 0 ) ? null : $f_master_bug_id ) ?> + <?php print_custom_field_input( $t_def, ( $f_master_bug_id === 0 ) ? null : $f_master_bug_id, $t_def['require_report'] ) ?> </td> </tr> <?php Index: bug_update_page.php =================================================================== --- bug_update_page.php (revision 13708) +++ bug_update_page.php (working copy) @@ -709,7 +709,7 @@ echo '<span>', string_display( lang_get_defaulted( $t_def['name'] ) ), '</span>'; echo '</label>'; echo '</td><td colspan="5">'; - print_custom_field_input( $t_def, $t_bug_id ); + print_custom_field_input( $t_def, $t_bug_id, $t_def['require_update'] ); echo '</td></tr>'; } } # foreach( $t_related_custom_field_ids as $t_id ) Index: core/cfdefs/cfdef_standard.php =================================================================== --- core/cfdefs/cfdef_standard.php (revision 13708) +++ core/cfdefs/cfdef_standard.php (working copy) @@ -280,9 +280,10 @@ * print_custom_field_input * @param array $p_field_def Custom field definition. * @param mixed $p_custom_field_value Custom field value. + * @param string $p_required The "required" attribute to add to the field * @return void */ -function cfdef_input_list( array $p_field_def, $p_custom_field_value ) { +function cfdef_input_list( array $p_field_def, $p_custom_field_value, $p_required = '' ) { $t_values = explode( '|', custom_field_prepare_possible_values( $p_field_def['possible_values'] ) ); $t_list_size = $t_possible_values_count = count( $t_values ); @@ -295,9 +296,9 @@ } if( $p_field_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST ) { - echo '<select ' . helper_get_tab_index() . ' id="custom_field_' . $p_field_def['id'] . '" name="custom_field_' . $p_field_def['id'] . '[]" size="' . $t_list_size . '" multiple="multiple">'; + echo '<select ' . helper_get_tab_index() . ' id="custom_field_' . $p_field_def['id'] . '" name="custom_field_' . $p_field_def['id'] . '[]" size="' . $t_list_size . '" multiple="multiple"' . $p_required .'>'; } else { - echo '<select ' . helper_get_tab_index() . ' id="custom_field_' . $p_field_def['id'] . '" name="custom_field_' . $p_field_def['id'] . '" size="' . $t_list_size . '">'; + echo '<select ' . helper_get_tab_index() . ' id="custom_field_' . $p_field_def['id'] . '" name="custom_field_' . $p_field_def['id'] . '" size="' . $t_list_size . '"' . $p_required .'>'; } $t_selected_values = explode( '|', $p_custom_field_value ); @@ -315,9 +316,10 @@ * print_custom_field_input * @param array $p_field_def Custom field definition. * @param mixed $p_custom_field_value Custom field value. + * @param string $p_required The "required" attribute to add to the field * @return void */ -function cfdef_input_checkbox( array $p_field_def, $p_custom_field_value ) { +function cfdef_input_checkbox( array $p_field_def, $p_custom_field_value, $p_required = '' ) { $t_values = explode( '|', custom_field_prepare_possible_values( $p_field_def['possible_values'] ) ); $t_checked_values = explode( '|', $p_custom_field_value ); for( $i = 0; $i < count( $t_values ); $i++ ) { @@ -324,7 +326,7 @@ $t_input_id = 'custom_field_' . $p_field_def['id'] . '_value_' . $i; $t_input_name = 'custom_field_' . $p_field_def['id'] . '[]'; echo '<label for="' . $t_input_id . '">' . "\n"; - echo '<input class="ace" id="' . $t_input_id . '" ' . helper_get_tab_index() . ' type="checkbox" name="' . $t_input_name . '" value="' . string_attribute( $t_values[$i] ) . '"'; + echo '<input class="ace" id="' . $t_input_id . '" ' . helper_get_tab_index() . ' type="checkbox" name="' . $t_input_name . '" value="' . string_attribute( $t_values[$i] ) . '"' . $p_required; check_checked( $t_checked_values, $t_values[$i] ); echo " />\n"; echo '<span class="lbl"> ' . string_display_line( $t_values[$i] ) . '</label>' . "\n"; @@ -336,9 +338,10 @@ * print_custom_field_input * @param array $p_field_def Custom field definition. * @param mixed $p_custom_field_value Custom field value. + * @param string $p_required The "required" attribute to add to the field * @return void */ -function cfdef_input_radio( array $p_field_def, $p_custom_field_value ) { +function cfdef_input_radio( array $p_field_def, $p_custom_field_value, $p_required = '' ) { $t_values = explode( '|', custom_field_prepare_possible_values( $p_field_def['possible_values'] ) ); $t_len = strlen( $p_custom_field_value ); @@ -352,7 +355,7 @@ $t_input_id = 'custom_field_' . $p_field_def['id'] . '_value_' . $i; $t_input_name = 'custom_field_' . $p_field_def['id']; echo '<label for="' . $t_input_id . '">'; - echo '<input class="ace" id="' . $t_input_id . '" ' . helper_get_tab_index() . ' type="radio" name="' . $t_input_name . '" value="' . string_attribute( $t_values[$i] ) . '"'; + echo '<input class="ace" id="' . $t_input_id . '" ' . helper_get_tab_index() . ' type="radio" name="' . $t_input_name . '" value="' . string_attribute( $t_values[$i] ) . '"' . $p_required; check_checked( $t_checked_value, $t_values[$i] ); echo " />\n"; echo '<span class="lbl"> ' . string_display_line( $t_values[$i] ) . '</span>' . "\n"; @@ -364,10 +367,11 @@ * print_custom_field_input * @param array $p_field_def Custom field definition. * @param mixed $p_custom_field_value Custom field value. + * @param string $p_required The "required" attribute to add to the field * @return void */ -function cfdef_input_textbox( array $p_field_def, $p_custom_field_value ) { - echo '<input ' . helper_get_tab_index() . ' type="text" id="custom_field_' . $p_field_def['id'] . '" name="custom_field_' . $p_field_def['id'] . '" size="80"'; +function cfdef_input_textbox( array $p_field_def, $p_custom_field_value, $p_required = '' ) { + echo '<input ' . helper_get_tab_index() . ' type="text" id="custom_field_' . $p_field_def['id'] . '" name="custom_field_' . $p_field_def['id'] . '" size="80"' . $p_required; if( 0 < $p_field_def['length_max'] ) { echo ' maxlength="' . $p_field_def['length_max'] . '"'; } else { @@ -380,10 +384,11 @@ * print_custom_field_input * @param array $p_field_def Custom field definition. * @param mixed $p_custom_field_value Custom field value. + * @param string $p_required The "required" attribute to add to the field * @return void */ -function cfdef_input_textarea( array $p_field_def, $p_custom_field_value ) { - echo '<textarea class="form-control" ' . helper_get_tab_index() . ' id="custom_field_' . $p_field_def['id'] . '" name="custom_field_' . $p_field_def['id'] . '"'; +function cfdef_input_textarea( array $p_field_def, $p_custom_field_value, $p_required = '' ) { + echo '<textarea class="form-control" ' . helper_get_tab_index() . ' id="custom_field_' . $p_field_def['id'] . '" name="custom_field_' . $p_field_def['id'] . '"' . $p_required; echo ' cols="70" rows="8">' . $p_custom_field_value .'</textarea>'; } @@ -392,9 +397,10 @@ * * @param string $p_field_def The custom field definition. * @param string $p_custom_field_value The custom field value to print. + * @param string $p_required The "required" attribute to add to the field * @return void */ -function cfdef_input_date( $p_field_def, $p_custom_field_value ) { +function cfdef_input_date( $p_field_def, $p_custom_field_value, $p_required = '' ) { print_date_selection_set( 'custom_field_' . $p_field_def['id'], config_get( 'short_date_format' ), $p_custom_field_value, false, true ); } Index: core/custom_field_api.php =================================================================== --- core/custom_field_api.php (revision 13708) +++ core/custom_field_api.php (working copy) @@ -1372,10 +1372,11 @@ * NOTE: This probably belongs in the print_api.php * @param array $p_field_def Custom field definition. * @param integer $p_bug_id A bug identifier. + * @param boolean $p_required True if the field is required for form submission * @return void * @access public */ -function print_custom_field_input( array $p_field_def, $p_bug_id = null ) { +function print_custom_field_input( array $p_field_def, $p_bug_id = null, $p_required = false ) { if( null === $p_bug_id ) { $t_custom_field_value = custom_field_default_to_value( $p_field_def['default_value'], $p_field_def['type'] ); } else { @@ -1392,7 +1393,7 @@ global $g_custom_field_type_definition; if( isset( $g_custom_field_type_definition[$p_field_def['type']]['#function_print_input'] ) ) { - call_user_func( $g_custom_field_type_definition[$p_field_def['type']]['#function_print_input'], $p_field_def, $t_custom_field_value ); + call_user_func( $g_custom_field_type_definition[$p_field_def['type']]['#function_print_input'], $p_field_def, $t_custom_field_value, $p_required ? ' required ' : '' ); print_hidden_input( custom_field_presence_field_name( $p_field_def['id'] ), '1' ); } else { trigger_error( ERROR_CUSTOM_FIELD_INVALID_DEFINITION, ERROR ); Index: manage_proj_create_page.php =================================================================== --- manage_proj_create_page.php (revision 13708) +++ manage_proj_create_page.php (working copy) @@ -101,7 +101,7 @@ <span class="required">*</span> <?php echo lang_get( 'project_name' ) ?> </td> <td> - <input type="text" id="project-name" name="name" class="input-sm" size="60" maxlength="128" /> + <input type="text" id="project-name" name="name" class="input-sm" size="60" maxlength="128" required /> </td> </tr> <tr> Index: manage_proj_edit_page.php =================================================================== --- manage_proj_edit_page.php (revision 13708) +++ manage_proj_edit_page.php (working copy) @@ -116,7 +116,7 @@ <span class="required">*</span> <?php echo lang_get( 'project_name' ) ?> </td> <td> - <input type="text" id="project-name" name="name" class="input-sm" size="60" maxlength="128" value="<?php echo string_attribute( $t_row['name'] ) ?>" /> + <input type="text" id="project-name" name="name" class="input-sm" size="60" maxlength="128" value="<?php echo string_attribute( $t_row['name'] ) ?>" required /> </td> </tr> <tr> @@ -849,7 +849,7 @@ <span class="required">*</span> <?php echo lang_get( 'username' ) ?> </td> <td> - <select id="project-add-users-username" name="user_id[]" class="input-sm" multiple="multiple" size="10"><?php + <select id="project-add-users-username" name="user_id[]" class="input-sm" multiple="multiple" size="10" required><?php foreach( $t_users AS $t_user_id=>$t_display_name ) { echo '<option value="', $t_user_id, '">', $t_display_name, '</option>'; } ?> Index: manage_tags_page.php =================================================================== --- manage_tags_page.php (revision 13708) +++ manage_tags_page.php (working copy) @@ -208,7 +208,7 @@ <span class="required">*</span> <?php echo lang_get( 'tag_name' ) ?> </td> <td> - <input type="text" id="tag-name" name="name" class="input-sm" size="40" maxlength="100" /> + <input type="text" id="tag-name" name="name" class="input-sm" size="40" maxlength="100" required /> <small><?php echo sprintf( lang_get( 'tag_separate_by' ), config_get( 'tag_separator' ) ); ?></small> </td> </tr> Index: news_edit_page.php =================================================================== --- news_edit_page.php (revision 13708) +++ news_edit_page.php (working copy) @@ -116,7 +116,7 @@ <span class="required">*</span> <?php echo lang_get( 'headline' ) ?> </td> <td> - <input type="text" id="news-update-headline" name="headline" class="input-sm" size="64" maxlength="64" value="<?php echo $v_headline ?>" /> + <input type="text" id="news-update-headline" name="headline" class="input-sm" size="64" maxlength="64" value="<?php echo $v_headline ?>" required /> </td> </tr> <tr> @@ -124,7 +124,7 @@ <span class="required">*</span> <?php echo lang_get( 'body' ) ?> </td> <td> - <textarea class="form-control" id="news-update-body" name="body" cols="60" rows="10"><?php echo $v_body ?></textarea> + <textarea class="form-control" id="news-update-body" name="body" cols="60" rows="10" required><?php echo $v_body ?></textarea> </td> </tr> <tr> Index: news_menu_page.php =================================================================== --- news_menu_page.php (revision 13708) +++ news_menu_page.php (working copy) @@ -75,7 +75,7 @@ <span class="required">*</span> <?php echo lang_get( 'headline' ) ?> </td> <td> - <input type="text" id="news-headline" name="headline" class="input-sm" size="64" maxlength="64" /> + <input type="text" id="news-headline" name="headline" class="input-sm" size="64" maxlength="64" required /> </td> </tr> <tr> @@ -83,7 +83,7 @@ <span class="required">*</span> <?php echo lang_get( 'body' ) ?> </td> <td> - <textarea class="form-control" id="news-body" name="body" cols="60" rows="8"></textarea> + <textarea class="form-control" id="news-body" name="body" cols="60" rows="8" required></textarea> </td> </tr> <tr> Index: proj_doc_add_page.php =================================================================== --- proj_doc_add_page.php (revision 13708) +++ proj_doc_add_page.php (working copy) @@ -80,7 +80,7 @@ <span class="required">*</span> <?php echo lang_get( 'title' ) ?> </th> <td width="75%"> - <input type="text" name="title" class="input-sm" size="70" maxlength="250" /> + <input type="text" name="title" class="input-sm" size="70" maxlength="250" required /> </td> </tr> <tr> @@ -98,7 +98,7 @@ <?php print_max_filesize( $t_max_file_size ); ?> </td> <td> - <input type="hidden" name="max_file_size" value="<?php echo $t_max_file_size ?>" /> + <input type="hidden" name="max_file_size" value="<?php echo $t_max_file_size ?>" required /> <input name="file" type="file" size="70" /> </td> </tr> Index: proj_doc_edit_page.php =================================================================== --- proj_doc_edit_page.php (revision 13708) +++ proj_doc_edit_page.php (working copy) @@ -102,7 +102,7 @@ <span class="required">*</span> <?php echo lang_get( 'title' ) ?> </th> <td width="80%"> - <input type="text" name="title" class="input-sm" size="70" maxlength="250" value="<?php echo $v_title ?>" /> + <input type="text" name="title" class="input-sm" size="70" maxlength="250" value="<?php echo $v_title ?>" required /> </td> </tr> <tr> |
|
MantisBT: master f4137abe 2017-02-08 14:12 Saga Musix Committer: dregad Details Diff |
Add HTML5 'required' attribute to form fields Fixes 0022310 Signed-off-by: Damien Regad <dregad@mantisbt.org> |
Affected Issues 0022310, 0023507 |
|
mod - account_page.php | Diff File | ||
mod - account_prof_edit_page.php | Diff File | ||
mod - account_prof_menu_page.php | Diff File | ||
mod - bug_change_status_page.php | Diff File | ||
mod - bug_report_page.php | Diff File | ||
mod - bug_update_page.php | Diff File | ||
mod - core/cfdefs/cfdef_standard.php | Diff File | ||
mod - core/custom_field_api.php | Diff File | ||
mod - core/date_api.php | Diff File | ||
mod - manage_proj_create_page.php | Diff File | ||
mod - manage_proj_edit_page.php | Diff File | ||
mod - manage_tags_page.php | Diff File | ||
mod - news_edit_page.php | Diff File | ||
mod - news_menu_page.php | Diff File | ||
mod - proj_doc_add_page.php | Diff File | ||
mod - proj_doc_edit_page.php | Diff File |