Share » Forums » Developer » Decide if class attribute is required...

Decide if class attribute is required on the fly

Decide if class attribute is required on the fly

Sunday 22 May 2005 12:41:44 am - 6 replies

Author Message

Paul Forsyth

Sunday 22 May 2005 5:57:26 am

You could also use javascript to check on the dependancy if you can use js.

Ini files may be preferrable to specific options in the class.

paul

Thomas Nunninger

Sunday 22 May 2005 8:20:47 am

Wtih JavaScript I'm not sure if someone deactivated it...

> Ini files may be preferrable to specific options in the class.

I don't understand what you want me to tell :(

Paul Forsyth

Sunday 22 May 2005 10:14:37 am

Take this ini setting i've made up, say in site.ini:

[RequiredClassAttributes]
RequiredAttributes[]=
RequiredAttributes[]=99

And in your template you could try with:

{let requiredAttributes=ezini("RequiredClassAttributes","RequiredAttributes","site.ini")
   myClassAttributeID=$myAttribute.contentclassattribute_id}

{section show=or($requiredAttributes|contains($myClassAttributeID),$myAttribute.contentclass_attribute.is_required)}
Hey, im required.
{section-else}
Im not required.
{/section}

{/let}

I feel this is a little easier to do than with the class system or with a workflow.

Hope it helps!

Paul

Thomas Nunninger

Sunday 22 May 2005 11:50:35 am

Thank you for this good idea with the ini file.

The only problem: when validating the input, eZ publish itself won't check if there is input given in the additional required fields because they are not defined as required in the class definition. One solution (but not very nice): declare all attributes as required and fill e.g. the company name with nonsens in a hidden HTML input field if it is a normal user.

Any better idea. Am I right, that there is no simple way to tell eZ publish "When validation this user's data consider the attribute 'company name' as required."

Thomas

Paul Forsyth

Sunday 22 May 2005 12:08:33 pm

Putting a workflow for before user/register would allow you get by this but its a little messy to implement :(

I've used hidden fields in the past to 'prefill' such information. You could use the example code i gave earlier to decide whether to show a proper input field or a hidden one. And set the hidden field to 'No company'. If the text is suitable its not actually too bad.

If you dont this information shown to users you could always test for this string, and whether anything was chosen in your other attributes, and show or not show in other templates.

Paul

Thomas Nunninger

Sunday 22 May 2005 12:26:47 pm

Thank you. I think I will find a solution.

Have a nice evening

Thomas

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu