I have a model, and that model has a few items in it, eg:
I'd like to dynamically show content once a user selects a type, then return that content as an array to $data - and ultimately create the item. *Note* The types aren't identical in the parameters they contain, eg type 'text' might require length, and text, while 'number' might require default, min and max.
I wasn't entirely sure how to go about this so I've created a model for each type, and use a dropdown to render that types options, eg:
The actionShowAttributes method simply loads the correct model based on type and calls render partial on a view: '_attributes' which then displays each attribute related to the type.
I'm now stuck. How do I go about turning the data into an array, and sending it back to $rule variable? When I submit the form, the only $_POST data that is submitted appears to be that of the original model used to create the form.
Alternately, is there a better way of accomplishing this?
Thanks in advance!
$name; //A text field $type; //A dropdown with a few options $data;
I'd like to dynamically show content once a user selects a type, then return that content as an array to $data - and ultimately create the item. *Note* The types aren't identical in the parameters they contain, eg type 'text' might require length, and text, while 'number' might require default, min and max.
I wasn't entirely sure how to go about this so I've created a model for each type, and use a dropdown to render that types options, eg:
<?php $form->dropdownListRow($model, 'type', array_merge(array(''=>'---'),ProfileFieldRule::itemAlias('type')) , array('class' => 'span5', 'maxlength' => 45, 'ajax'=>array( 'type'=>'POST', 'url'=>CController::createUrl('ProfileFieldRule/showAttributes'), 'update'=>'#showAttributes', )))); ?> <div id="showAttributes"></div>
The actionShowAttributes method simply loads the correct model based on type and calls render partial on a view: '_attributes' which then displays each attribute related to the type.
$this->renderPartial('_attributes', $data, false, true);
I'm now stuck. How do I go about turning the data into an array, and sending it back to $rule variable? When I submit the form, the only $_POST data that is submitted appears to be that of the original model used to create the form.
Alternately, is there a better way of accomplishing this?
Thanks in advance!