weno Posted July 4, 2014 Share Posted July 4, 2014 Hi,I have implemented a tabular input form by using two models - model(Booking) and item(BookingForm- multiple models are kept in an Items array). I pass model and Items to the booking form and loop through the items. Is this the correct way to implement this kindof form? BookingForm is an intermediary table. All the functionality is working on the page, but there is a missing asterisk from next to the first form field. The other fields have their asterisks and I have set the required rules appropriately. I also wondered if anyone could tell me about... CActiveForm::validateTabular(). I have implemented ajax validation for a single model, but the way I have implemented it for tabular data doesn't seem to work - adding Items as an arguement in performAjaxValidation($model, $items) then appending output onto the existing echo. I am new to frameworks and Yii so I may not be doing the right thing. Thanks, James Link to comment Share on other sites More sharing options...
Larry Posted July 11, 2014 Share Posted July 11, 2014 Could you share the code you're using? Specifically, the relations and validation rules in the models, and the view code involved. Link to comment Share on other sites More sharing options...
weno Posted July 11, 2014 Author Share Posted July 11, 2014 Hi Larry, thanks for the reply. I've had a look at the asterisk problem and solved it - it was fairly simple I just entered the wrong variable for LabelEx attribute - it should have been 'roomId' not 'Room No'. Sorry about that. I have completely changed my app now and what am I stuck with is getting validation to work for forms built with formbuilder. I have followed the section in your book, but validation messages won't display. Here is my code if you would be willing to look at it: The form displays, but the validation error messages won't display. -- Fixed this problem now. The button for submit was called 'Login' when it should have been submit. 'login'=>array('type'=>'submit','label'=>'Submit',), 'submit'=>array('type'=>'submit','label'=>'Submit',), List action from Room controller public function actionList() { $model = new ListForm; $form = new CForm('application.views.site.listForm', $model); var_dump($model->arrive); if ($form->submitted() && $form->validate()) { $this->redirect(array('site/index')); } else{ $this->render('list', array('model' => $model, 'form' => $form)); } } Array in listForm <?php return array( 'title'=>'Please provide your login credential', 'elements'=>array( 'arrive'=>array( 'type'=>'date', 'required'=>true ), 'email'=>array( 'type'=>'date', 'required'=>true ), 'subject'=>array( 'type'=>'checkbox', 'required'=>true ) ), 'buttons'=>array( 'login'=>array( 'type'=>'submit', 'label'=>'Submit', ), ), ); public function rules() { return array( // name, email, subject and body are required array('arrive, email, subject', 'required') // email has to be a valid email address //array('email', 'email'), // verifyCode needs to be entered correctly //array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()), ); } Rules from the ListForm model ^ and the list form <div class="form"> <?php echo $form; ?> </div> Link to comment Share on other sites More sharing options...
Larry Posted August 8, 2014 Share Posted August 8, 2014 Sorry for the delay on this; busy summer, and on vacation. Do you still need help here? Link to comment Share on other sites More sharing options...
Recommended Posts