Forums / Setup & design / Class attribute - help

Class attribute - help

Author Message

Hugo Oliveira

Monday 10 September 2007 5:29:47 pm

Hi

First of all I'd like to apologize if this topic is in the wrong place.

I've got a class with an attribute that (ideally) could be one of 2 things: a hyperlink or a file. Is there a way to define a class to harbor such a constraint? This attribute should never be both at the same time. Is there a way to do this with just a class definition?

Thanks in advance.

Olivier Ouin

Monday 17 September 2007 8:25:06 am

I think it's not possible to do it only with a new class.

For me, the simpliest way is to create a class with the 2 attributes, with a custom edit template that allow to input only one of them (javascript validation prior to post, by example).

More sophisticated, you can deleguate creation of these objects to a custom module, calling for a custom template.

Another solution could be the custom datatype which will reject validation if link and file are submited, but it's maybe a kind of overkill.