Dynamically create Attributes (= textFields) for CFormModel ?

Hi,

I have a Form with dynamicly created fields.

Therefore the attributes in my CFormModel have to be created dynamicly to!

This is how my formFields are created ($i=10 is just an example, the value of $i could be any number):




<?php

class XForm extends CFormModel {


	// Static Attributes

	public $xxxx;


	// Validation here...


	// Create TextFields for Form with "new" attributes

	public function getTimeDateFields($form, $model)

	{

		$outputString = '';

		for($i = 0; $i <= 10 ; $i++)

		{

			$outputString .= '<div>'.$form->textField($model,'FIELD_'.$i).'</div>';	

		}

		return $outputString;

	}

?>



[b]How do I assign these new properties to the CFormModel?

How do I assign validation rules to these new properties?[/b]

I already experimented with __GET __SET, but had no success

THX

Andreas

Here is what I think you can do (more like an idea, no code was tested).

Add a public property/variable to your model class name something like datetimes.

Then create fields in your view with name datetimes[].

When you assign model’s attributes property in your controller like so $model->attributes = $_POST[‘Form’], datetimes property in model will contain php array of datetime values from the form.

After you can add a custom validation rule for it.