As this module works with form fields that are empty, and most forms are prompting people to input information, it would be lovely to be able to highlight ( or even lowlight ) those fields for which no user input has been submitted.

Just a thought.

Cheers

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Alan D.’s picture

Status: Active » Closed (won't fix)

Unless someone can think of an easy clean way to implement this, I'm marking as won't fix. (I tried 3 or 4 ways, but the classes were not coming through)

vadym.kononenko’s picture

Version: 7.x-2.0-rc1 » 7.x-2.x-dev
Issue summary: View changes
Status: Closed (won't fix) » Needs review
FileSize
1.71 KB

Could we do it on client side through JS?

TwoD’s picture

Here's an implementation which doesn't rely on JS, and it could allow things like themes to check if this module considers a field empty by looking for the extra flag on field.

Alan D.’s picture

Nice, this approach looks good, but a few changes.

1) Skip "'#empty_fields_is_empty' => TRUE," for just "if (!empty($variables['element']['#empty_fields_empty_class'])) {"?

2) Possible security hole?


function template_process(&$variables, $hook) {
  // Flatten out classes.
  $variables['classes'] = implode(' ', $variables['classes_array']);
...
}

function theme_field($variables) {
....
  // Render the top-level DIV.
  $output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>';

  return $output;
}

3) Tiny decluttered...

  // Check if within the Views field options.
  if ($context['instance']['entity_type'] == 'ctools' && $context['view_mode'] == '_custom') {
    $state_trigger_prefix = 'options[settings]';
  }
  else {
    $state_trigger_prefix = 'fields[' . $context['field']['field_name'] . '][settings_edit_form][settings]';
  }

Attached is a totally untested patch.

Alan D.’s picture

...missed a bit in that 5 min hack. Having to run for some takeout (dinner time here) before going back to a clients project again.

Let me know if it is good or bad to keep or remove, regarding point #1.

Without the checkbox, simply checking empty_fields_handler != '' for the empty class visibility maybe?

TwoD’s picture

1) Agreed, just looking at if a class gets set simplifies it.

2) Indeed, I assumed that array passed through drupal_attributes(), good catch.

Added a row to the summary when a class gets set, completed the renaming to $state_trigger_prefix, removed the extra checkbox in favor of just checking if the class list is empty, now splitting the string on spaces and running each segment through drupal_html_class() instead of check_plain(), and some minor cleanups.

  • Alan D. committed 4e30bf2 on 7.x-2.x authored by TwoD
    Issue #1884544 by TwoD, Alan D., vadym.kononenko: Inject CSS class when...
Alan D.’s picture

Status: Needs review » Fixed

Nice. I done some local testing with no issues seen and it does what it is meant to.

Pushed through :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.