By drupalzack on
I'm looking for some info on theming cck fields in edit mode. I started with content-field-my_field.tpl.php, but that themes the cck field during display rather than while editing.
What is the best approach to modify the look and feel of a cck type when in node edit mode?
Thanks for any suggestions!
Comments
style.css or hook_form_alter
Use something like Firebug in Firefox (or simply view the html source of the edit page) to determine the class/id of the particular field you wish to theme when you are on a node edit page that uses that field, and then modify this style in style.css in the theme folder you are using for the site.
If you're using the same field in multiple nodes, and only wish to modify it in a particular node, one way to isolate this is by using the hook_form_alter function. Do this by creating your own custom module called "modulename", for example. Create a folder inside your sites/all/modules folder called "modulename". Inside of this you will at least need two files (modulename.info and modulename.module). See http://drupal.org/node/206756 for an in-depth explanation on .info files (for the purpose we are discussing here, you would just need a very basic modulename.info file). The modulename_form_alter function would go in the modulename.module file, and might look something like this in your scenario...
Above, myfieldname is the name of your cck field in the $form array, while #prefix and #suffix are added before and after the field, as defined by the Drupal Forms API, allowing you to encompass your field in a custom css class. The Forms API reference shows all aspects of the different types of fields that can be modified via a form_alter function. Once you are done with your custom module make sure to install it and enable it. Otherwise your form_alter function will do nothing.
Hope this helps. Let me know if I can clarify anything.