alter imagefield field
Hi everyone !
I need your help to resolve my problem.
I created a cck imagefield in my content type. The maximum values for this field is unlimited. But sometime, I need to alter this value (limit this value to 1 for exemple). You know how I can do that ? Probably I can use hook_form_alter but I don't find the parameter to overwrite (list, delta...) ???
Thanks for your help !
Julien
Groups:
Login to post comments

Hi Julien, It seems odd that
Hi Julien,
It seems odd that in the same content type you would need to limit the number of images on some nodes, but not others. What are you trying to do? Perhaps there is a better way.
--
Dave Hansen-Lange
Web Developer
Advomatic LLC
East Asia Office
Hong Kong
Well I need to limit the
Well I need to limit the number of images an user can attach in a node. This limit depend of the user's role and number of nodes who already have multiples images. For exemple, an user with a "customer free account"'s role cannot have more than 3 products with multiples images. But he can create 50 products if he want (but all others products can have only one image).
I created my own module to apply all rules. But my last step is to overwrite the "maximum values" parameter of my field. How I can do that ?
Julien Didelet
For the moment I realized
For the moment I realized that with jquery (hide()) but it's not very clean.
Julien Didelet
I'm not sure about your
I'm not sure about your business case, but here are just some ideas that popped into my head
If it is easy for you to limit the number of nodes based on content type and user role, then you can create two content types:
Product (can have unlimited images)
Limited Product (can only have one image)
Again, I'm not sure how much logic you already have in your rules, so this may not apply.
Russell JVM Gutierrez
Manager, Hong Kong Projects
flippingNORMALS
Web | Social Media | Mobile
Thanks for your idea but it's
Thanks for your idea but it's not possible. I don't want create two type of nodes. I just want one type of content type (here product) and just alter the parameter in my imagefield. For the moment, I found temporary solution with jquery (just hide() the field). But it's not very clean. I prefer to find a solution with nodeapi (case "prepare") and an other function. But I don't know how I can change this maximum values...
Julien Didelet
Yeah I'd recommend not
Yeah I'd recommend not creating a second content type. Content types seem like an easy way out at first, but will quickly become a maintenance nightmare if you are overusing them. Julien I think you are on the right track with hook_form_alter and hook_nodeapi. Sorry I can't give you more specific direction.
--
Dave Hansen-Lange
Web Developer
Advomatic LLC
East Asia Office
Hong Kong
Ok thanks no problem. I'll
Ok thanks no problem. I'll hope find a solution quickly :).
Julien Didelet