I want to show some dynamic content to the user, so use a dropdown like so:
the action showAttributes renders some form elements, stuff like:
Question 1 At this point, I'd like to know if there's a way I can access the $form variable that was created in the view? It's easier, than CHtml and if I make changes they'd persist I wouldn't have to come update them again here. If not, that's ok, I can work with CHtml.
**So far so good, until the form is submitted with errors. At that point, the generated content disappears until you change the dropdown again.**
Question 2 What's the best way to make it persist? At present I check if it's set and copy the code from showAttributes. This seems pretty redundant.
Question 3 How would I go about adding ajax validation to this form? The non dynamic portion is simple, but I don't know how to add the dynamic attributes to what's being validated.
Thanks in advance for any help, hopefully I've made it more clear with this edit!
<?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',
))));
?>the action showAttributes renders some form elements, stuff like:
echo CHtml::activeDropDownList($attr, $name, array('true', 'false'));Question 1 At this point, I'd like to know if there's a way I can access the $form variable that was created in the view? It's easier, than CHtml and if I make changes they'd persist I wouldn't have to come update them again here. If not, that's ok, I can work with CHtml.
**So far so good, until the form is submitted with errors. At that point, the generated content disappears until you change the dropdown again.**
Question 2 What's the best way to make it persist? At present I check if it's set and copy the code from showAttributes. This seems pretty redundant.
Question 3 How would I go about adding ajax validation to this form? The non dynamic portion is simple, but I don't know how to add the dynamic attributes to what's being validated.
Thanks in advance for any help, hopefully I've made it more clear with this edit!