2013-11-27 3 views
1

내 양식에 CMaskedTextField가 있는데,이를 채울 때 $ _POST []에서 값을 반환하지 않습니다! 당신이 당신이 model 다음 name를 제거하고 attribute를 추가해야 사용하려면, 위젯에서Chtml Cmaskedtextfield가 값을 보내지 않습니까?

<?php echo CHtml::label(Yii::t('models', 'form.label.position'), 'position'); ?> 
    <?php 
    $this->widget('CMaskedTextField', array(
      'name' => "position", 
      'mask' => '999', 
      'htmlOptions' => array(
      'size' => 5, 
      'placeholder' => Yii::t('models', 'form.hint.position'), 
      'title' => Yii::t('models', 'form.hint.position'), 
      ), 
    )); 
    ?> 

:

<?php echo CHtml::label(Yii::t('models', 'form.label.position'), 'position'); ?> 
    <?php 
    $this->widget('CMaskedTextField', array(
      'model' => null, 
      'name' => "position", 
      'mask' => '999', 
      'htmlOptions' => array(
      'size' => 5, 
      'placeholder' => Yii::t('models', 'form.hint.position'), 
      'title' => Yii::t('models', 'form.hint.position'), 
      ), 
    )); 
    ?> 

답변

0

당신은 같은 'model' => null을 제거 시도 할 수 있습니다.

은 내 양식에서

업데이트 : 내가 가진 뷰를 가지고있는 형태와 같은 :

<?php echo CHtml::beginForm('post/test', 'post'); ?> 

    <?php echo CHtml::errorSummary($model); ?> 

    <div class="row"> 
     <?php echo CHtml::label(Yii::t('models', 'form.label.position'), 'position'); > 
    <?php 
    $this->widget('CMaskedTextField', array(   
      'name' => "position", 
      'mask' => '999', 
      'htmlOptions' => array(
      'size' => 5, 
      'placeholder' => 'place holder', 
      'title' => 'title' 
      ), 
    )); 
    ?> 
    </div> 

    <div class="row submit"> 
     <?php echo CHtml::submitButton('test'); ?> 
    </div> 

<?php echo CHtml::endForm(); ?> 

그리고 나는 또한 test 행동처럼 들어있는 PostController 있습니다

public function actionTest() 
    {  
     var_dump($_POST); 
    } 

을 괜찮 았어.

array (size=2) 
    'position' => string '234' (length=3) 
    'yt0' => string 'test' (length=4) 

그래서 당신이 양식이 POST 방식으로 전송되고 당신이 당신의 maskedTextField를 작성 후 제출 것 가지고 있는지 확인하십시오.

+0

고맙습니다.하지만 답이 맞지 않아, 모델에 'model'=> null'이 (가) 있지만 $ _POST [ 'position']이 (가) 비어 있다고 말한대로 모델이 없습니다 .... – shgnInc

+0

@ Shgn.ir : 대답을 업데이트했습니다. 좀 봐주세요! – secretlm

+0

그래, 내가 다른 필드가 올바르게 전송되기 때문에 양식의 방법에 대해서는 정말 확신합니다. 'post ', array ('id '=>'form-id ',))'echo CHtml :: beginForm ($ this-> createUrl ('create ', array ('form '=> $ form_id) – shgnInc