T
T
Test Test2015-07-10 12:04:55
Yii
Test Test, 2015-07-10 12:04:55

How to solve problem with Yii forms?

Good afternoon. There was a problem with the forms, namely, I can’t figure out how to make the js code connect.
If you create a form on the same page, then everything will work.
https://yadi.sk/i/ZM_i0iikhnLwB
But my task is to create a form dynamically, via ajax. Let's say we add the code below to the page via ajax:

<?php $form = $this->beginWidget('UActiveForm', array(
    'id' => 'service-order-form-data',
    'enableAjaxValidation' => true,
    'clientOptions' => array(
      'validateOnSubmit' => true,
      'beforeValidate'=>'js:formServiceBeforeValidate',
      'afterValidate'=>'js:formServiceAfterValidate',
      'inputContainer' => 'fieldset',
      'successCssClass' => 'b-form-correct-fieldset',
      'errorCssClass' => 'b-form-wrong-fieldset',
      'validatingCssClass' => 'b-form-processed-fieldset',
    ),
    'htmlOptions' => array(
      'class' => 'b-form b-order-form g-cleared',
    ),
  )); ?>

  <fieldset class="b-form-fieldset b-form-required-fieldset">
    <?php echo $form->labelEx($dataOrder, 'comment', array('class' => 'b-form-fieldset-description')); ?>
    <?php echo $form->textArea($dataOrder, 'comment', array('class' => 'b-form-fieldset-text-input', 'style'  => 'height: 100px')); ?>
    <?php echo $form->error($dataOrder, 'comment', array('class' => 'b-form-fieldset-error')); ?>
  </fieldset>


  <fieldset class="b-form-fieldset b-form-submit-fieldset">
    <input class="b-form-fieldset-submit-input" id="store-order-form-canceled-submit" type="submit">
  </fieldset>

  <?php $this->endWidget(); ?>

Js-code for this form will not be generated. How can this problem be solved, sir? As an option, I guess, you need to make a function call that will output the generated code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Test Test, 2015-07-10
@cubooks

The solution is to make the right render.

$this->renderPartial('tmpl', array(
 'dataOrder' => $dataOrder,
), true, true);

first true - write code to string
second true - run js scripts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question