CCK field element combined validation
This is how you can programmatically create a combined validation.
This is how you can programmatically create a combined validation.
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:
Some good Drupal developer guides or reference pages
About overriding themable output http://drupal.org/node/173880
CCK for developers: http://drupal.org/node/101742
Content Construction Kit Handbook: http://drupal.org/modules/cck/documentation
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;
}
This is how I set default value on Nodereference autocomplete field in an after build function. First set an afterbuild function in form alter hook, then in the after build function set the value. In this case I have added two values in the path calling for the form, node/add/project/[Parent nid]/[Parent name]
This is how you can make a simplified node load function just for CCK fields to avoid all invoke calls.
This is how you can add validation and a calculation on a CCK field programmatically. i have a CCK field (integer) with unlimited number of items allowed. User can add the time in different formats and I have a restriction on min 15 minutes. The allowed format is:
[numeric]h[numeric]m like 3h15m
[numeric]h like 2h
[numeric]m like 45m
[numeric] like 60
One solution of the missing labels for CCK single on/off checkbox field is to allow Unlimited values, even if you only have one value to choose. For instance if you have CCK field "Auto publish" and you want one checkbox with the label "Auto publish" and the value besides the checkbox, like "Yes". One drawback of this is that the value don't appear on edit page...
Tried to use form_alter on CCK and even form_after_build but no success? Try out Prepopulate module http://drupal.org/project/prepopulate.