autocomplete

Nodereference views and dynamic argument

When using views as filter and need a dynamic argument set you can't use autocomplete widget type because it uses a pre-default value that you cant change in form_alter or after_build.

If you change the widget to Select list then you can use both form_alter and after_build to set the advanced_view_args item based on arg etc.

Same goes for using PHP field in views to set a default PHP based argument, it can't get the arg list you like to have (node/[nid]/..). The arg list looks like this when using autocomlete and PHP filed:

How to set read only on an CCK autocomplete field

This is how to set an attribute like read only on a CCK autocomplete field programmatically. You have to add a after_build function to execute the below code

<?php
/**
* After build function
*/
function content_log_after_build($form_element, &$form_state){
$form_element['field_l_reference'][0]['nid']['nid']['#attributes']['readonly'] = 'readonly';
}
?>

To style it

input[readonly="readonly"] {
background-color: #EEEEEE;
}