Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
fd8579a3
Commit
fd8579a3
authored
15 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#493520
by mfb and oneoftwo: Fixed Profile fields cannot be updated (with tests).
parent
d7b07976
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/profile/profile.admin.inc
+5
-5
5 additions, 5 deletions
modules/profile/profile.admin.inc
modules/profile/profile.test
+72
-3
72 additions, 3 deletions
modules/profile/profile.test
with
77 additions
and
8 deletions
modules/profile/profile.admin.inc
+
5
−
5
View file @
fd8579a3
...
...
@@ -317,7 +317,7 @@ function profile_field_form_validate($form, &$form_state) {
$query
->
fields
(
'profile_field'
,
array
(
'fid'
));
if
(
isset
(
$form_state
[
'values'
][
'fid'
]))
{
$query
->
condition
(
'fid'
,
$form_state
[
'values'
][
'fid'
]);
$query
->
condition
(
'fid'
,
$form_state
[
'values'
][
'fid'
]
,
'<>'
);
}
$query_name
=
clone
$query
;
...
...
@@ -356,9 +356,9 @@ function profile_field_form_submit($form, &$form_state) {
if
(
!
isset
(
$form_state
[
'values'
][
'page'
]))
{
$form_state
[
'values'
][
'page'
]
=
''
;
}
// Remove all elements that are not profile_field columns.
$values
=
array_intersect_key
(
$form_state
[
'values'
],
array_flip
(
array
(
'type'
,
'category'
,
'title'
,
'name'
,
'explanation'
,
'visibility'
,
'page'
,
'weight'
,
'autocomplete'
,
'required'
,
'register'
,
'options'
)));
if
(
!
isset
(
$form_state
[
'values'
][
'fid'
]))
{
// Remove all elements that are not profile_field columns.
$values
=
array_intersect_key
(
$form_state
[
'values'
],
array_flip
(
array
(
'type'
,
'category'
,
'title'
,
'name'
,
'explanation'
,
'visibility'
,
'page'
,
'weight'
,
'autocomplete'
,
'required'
,
'register'
,
'options'
)));
db_insert
(
'profile_field'
)
->
fields
(
$values
)
->
execute
();
...
...
@@ -367,9 +367,9 @@ function profile_field_form_submit($form, &$form_state) {
}
else
{
db_update
(
'profile_field'
)
->
fields
(
$
form_state
[
'
values
'
]
)
->
fields
(
$values
)
->
condition
(
'fid'
,
$form_state
[
'values'
][
'fid'
])
->
exe
u
cte
();
->
exec
u
te
();
drupal_set_message
(
t
(
'The field has been updated.'
));
}
cache_clear_all
();
...
...
This diff is collapsed.
Click to expand it.
modules/profile/profile.test
+
72
−
3
View file @
fd8579a3
...
...
@@ -67,6 +67,53 @@ class ProfileTestCase extends DrupalWebTestCase {
);
}
/**
* Update a profile field.
*
* @param $fid
* The fid of the field to be updated.
* @param $type
* The type of field to be updated.
* @param $edit
* Field parameters to be submitted.
* @return
* Array representation of the updated field.
*/
function
updateProfileField
(
$fid
,
$type
=
'textfield'
,
$edit
=
array
())
{
$form_name
=
$edit
[
'name'
];
$title
=
$edit
[
'title'
];
$category
=
$edit
[
'category'
];
$this
->
drupalPost
(
'admin/config/people/profile/edit/'
.
$fid
,
$edit
,
t
(
'Save field'
));
// Check that the updated field is appearing on the user edit form.
$this
->
drupalGet
(
'user/'
.
$this
->
admin_user
->
uid
.
'/edit/'
.
$category
);
// Checking field.
if
(
$type
==
'date'
)
{
$this
->
assertField
(
$form_name
.
'[month]'
,
t
(
'Found month selection field'
));
$this
->
assertField
(
$form_name
.
'[day]'
,
t
(
'Found day selection field'
));
$this
->
assertField
(
$form_name
.
'[year]'
,
t
(
'Found day selection field'
));
}
else
{
$this
->
assertField
(
$form_name
,
t
(
'Found form named @name'
,
array
(
'@name'
=>
$form_name
)));
}
// Checking name.
$this
->
assertText
(
$title
,
t
(
'Checking title for field %title'
,
array
(
'%title'
=>
$title
)));
// Checking explanation.
$this
->
assertText
(
$edit
[
'explanation'
],
t
(
'Checking explanation for field %title'
,
array
(
'%title'
=>
$title
)));
return
array
(
'fid'
=>
$fid
,
'type'
=>
$type
,
'form_name'
=>
$form_name
,
'title'
=>
$title
,
'category'
=>
$category
,
);
}
/**
* Set the profile field to a random value
*
...
...
@@ -140,10 +187,18 @@ class ProfileTestFields extends ProfileTestCase {
'url'
=>
'http://www.'
.
str_replace
(
'_'
,
''
,
$this
->
randomName
(
10
))
.
'.org'
,
);
// For each field type, create a field, give it a value and delete the field.
// For each field type, create a field, give it a value, update the field,
// and delete the field.
foreach
(
$field_types
as
$type
=>
$value
)
{
$field
=
$this
->
createProfileField
(
$type
);
$this
->
setProfileField
(
$field
,
$value
);
$edit
=
array
(
'name'
=>
$field
[
'form_name'
],
'title'
=>
$this
->
randomName
(),
'category'
=>
$field
[
'category'
],
'explanation'
=>
$this
->
randomName
(),
);
$field
=
$this
->
updateProfileField
(
$field
[
'fid'
],
$field
[
'type'
],
$edit
);
$this
->
deleteProfileField
(
$field
);
}
}
...
...
@@ -159,7 +214,7 @@ class ProfileTestSelect extends ProfileTestCase {
}
/**
* Create a list selection field, give it a value, and delete the field.
* Create a list selection field, give it a value,
update
and delete the field.
*/
function
testProfileSelectionField
()
{
$this
->
drupalLogin
(
$this
->
admin_user
);
...
...
@@ -171,6 +226,13 @@ class ProfileTestSelect extends ProfileTestCase {
$this
->
setProfileField
(
$field
,
rand
(
1
,
10
));
$edit
=
array
(
'name'
=>
$field
[
'form_name'
],
'title'
=>
$this
->
randomName
(),
'category'
=>
$field
[
'category'
],
'explanation'
=>
$this
->
randomName
(),
);
$field
=
$this
->
updateProfileField
(
$field
[
'fid'
],
$field
[
'type'
],
$edit
);
$this
->
deleteProfileField
(
$field
);
}
}
...
...
@@ -185,7 +247,7 @@ class ProfileTestDate extends ProfileTestCase {
}
/**
* Create a date field, give it a value, and delete the field.
* Create a date field, give it a value,
update
and delete the field.
*/
function
testProfileDateField
()
{
$this
->
drupalLogin
(
$this
->
admin_user
);
...
...
@@ -208,6 +270,13 @@ class ProfileTestDate extends ProfileTestCase {
$this
->
assertText
(
'01/09/1983'
,
t
(
'Found date profile field.'
));
$edit
=
array
(
'name'
=>
$field
[
'form_name'
],
'title'
=>
$this
->
randomName
(),
'category'
=>
$field
[
'category'
],
'explanation'
=>
$this
->
randomName
(),
);
$field
=
$this
->
updateProfileField
(
$field
[
'fid'
],
$field
[
'type'
],
$edit
);
$this
->
deleteProfileField
(
$field
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment