This question is about having a new component type at webforms (like i.e. webform/components/newcomponent.inc )

I need to have a new component there just like the current select BUT being hidden for the ones who fill the form in a first place. Just the editor roles I have created should see and edit it.

SO, it behaves like the hidden.inc component regarding visibility, but being like the select.inc

Thank you a lot

Comments

oscaral’s picture

Going deeper, I thought it should have been solved following these points:

- I am letting anonymous users to fill the form

- duplicating select.inc and renaming it (i.e., hidden_select.inc)

- changing there the names of the functions. For hidden_select.inc there would be functions like _webform_defaults_hidden_select(), and so on, and the references to these same functions inside this same .inc

- MAKING A CHANGE TO MAKE THE COMPONENT NOT VISIBLE <--- THIS IS the thing I need to know.
I thought it was this but it is not working:

function _webform_submission_display_hidden_select($data, $component, $enabled = FALSE) {
  $form_item = _webform_render_hidden_select($component);
 
  // --- CHANGE ADDED: Only allow administrators that can view or edit all submissions to view or edit hidden fields.
  if (user_access('edit webform submissions') || user_access('access webform results')) {
  	
	  if ($component['extra']['multiple'] === 'Y') {
	    // Set the value as an array.
	    $form_item['#default_value'] = array();
	    foreach ((array)$data['value'] as $key => $value) {
	      $form_item['#default_value'][] = $value;
	    }
	  }
	  else {
	    // Set the value as a single string.
	    $form_item['#default_value'] = '';
	    foreach ((array)$data['value'] as $value) {
	      $form_item['#default_value'] = $value;
	    }
	  }
	  $form_item['#disabled'] = !$enabled;
  

 } // <---CLOSING IF
  
  
  return $form_item;
}

It didn't work. The field is visible

- Deleting repeated functions (like webform_expand_checkboxes($element) that would be taken from select.inc instead)

- Saving it and clearing cache

ANY new ideas to solve this? Thank you a lot