Forces a default run nid to be inserted into the filter#6194
Forces a default run nid to be inserted into the filter#6194itsjoekent merged 4 commits intoDoSomethingArchive:devfrom
Conversation
| if ($form['#id'] == 'views-exposed-form-reportback-files-page-1') { | ||
| if (empty($_GET['run_nid'])) { | ||
| $run = dosomething_helpers_get_current_campaign_run_for_user(arg(1)); | ||
| if (isset($run)) { |
There was a problem hiding this comment.
Maybe !empty() will be better?
There was a problem hiding this comment.
No I only want this to run when the filter is empty. If I did !empty( it would run even when a user specifies a filter
There was a problem hiding this comment.
Yes, but I'm talking about asserting $run variable's existence.
There was a problem hiding this comment.
OHHHHHHHHHH
the if right above is empty and i thought thats what you were referring too.
The function im getting the run from returns NULL if it cant find it, so I dont think empty would work
There was a problem hiding this comment.
But !empty(NULL) is FALSE, as expected.
There was a problem hiding this comment.
And to be clear, dosomething_helpers_get_current_campaign_run_for_user() may return not just null, but FALSE and stdClass, see return node_load($run['id']);.
There was a problem hiding this comment.
and FYI
php > $false = FALSE;
php > var_dump(isset($false));
bool(true)|
Also, instead of altering a form, would it make sense to use one of view's hooks, like hook_views_pre_build or something? |
|
I've never gotten those view build hooks to work right, I find the form_alter to be much better |
|
Ok! |
|
My only concern is |
|
That was my first thought too when I noticed that, but no its always page-1. I have a feeling thats an old typo someone made haha |
|
26 comments - this escalated quickly. |
|
@sergii-tkachenko ok, i think we're good now 😪 |
| } | ||
|
|
||
|
|
||
| function dosomething_reportback_form_views_exposed_form_alter(&$form, &$form_state, $form_id) { |
|
Who would think this PR turned out to be so large. High five, @deadlybutter! |
|
hall of fame much |
Forces a default run nid to be inserted into the filter

What's this PR do?
Makes sure that the run nid on reportback view tab has a default value corresponding to the campaigns current default.
How should this be manually tested?
Go to a reportback review tab, is the correct thing filled out and does it show the correct reportbacks?
Any background context you want to provide?
I realized i didn't notice this the first time because on my machine the first ~10 reportbacks we're correct, but after that they were not. Whereas on Thor/Prod shit is just completely wrong and out of order.
What are the relevant tickets?
Fixes #6192