Hello.

I'm trying to disable [ or rather render invisible ] certain aspects of a node edit form based on user roles.

what i've been doing is switching the content type from either 'fieldset' or 'textfield' etc, to 'value'. this seems to work on a simple test, but i'm wondering if anyone sees pitfalls to this approach.

thank you in advance.

Comments

asparagus’s picture

not sure if this is an error on submitting a form or desired functionality.

if is manually set the '#type' value of 'options' for a story node via story-form.tpl.php to 'value' instead of 'fieldset' then it does not take the default or existing value into account and all options are reset to '0'.

i'm not changing any other value of the arrays. the contents of my story-form.tpl.php is below.

global $user;
$form['taxonomy']['#type'] = "value";
$form['author']['#type']  = "value";
$form['path']['#type']  = "value";
$form['comment_settings']['#type']  = "value";
$form['menu']['#type']  = "value";
if (!in_array('webmaster',$user->roles))
{
	$form['options']['#type']  = "value";
	$form['title']['#type'] = "value";
}
print form_render($form);
asparagus’s picture

I've tried simply looping through all of the 'options' setting and setting the '#type' to 'hidden'. This works, but leaves he fieldset tag, so i also get the border and title, but withough any contents. If i also set 'options' '#type' to 'hidden' then nothing prints. it would seem that i'm stuck showing this form section, but it seems like it shouldn't be so.

any thoughts?