submitting array

Hi there

first of all - sorry my English

How I can create form elements for submitting array?

I want to create something like this




<lable>Val 1</label><input name="arr[]" type="text"/><br/>

<lable>Val 2</label><input name="arr[]" type="text"/><br/>

<lable>Val 3</label><input name="arr[]" type="text"/><br/>

...



I’d tried to use




...

<?php echo CHtml::activeTextField($model,'arr[]'); ?>

...



but I get next HTML code




...

<input type=text name=Model[][arr]>

...



Is there a way to do this with Yii?

peace

Alex

try following~


CHtml::activeTextField($model,'[arr]');

try with http://www.yiiframework.com/doc/guide/form.table

this doesn’t work

Sorry I do not fully described what I need.

This don’t help me, I mean it works well but not for my situation,

but it gave me the idea.




    <div class="simple keyword_container">

        <?php $list = CHtml::listData(Keyword::model()->findAll(), 'id', 'name'); ?>

        <?php echo CHtml::activeLabelEx($model,'keyword'); ?>

        <?php echo CHtml::dropDownList('Domain[Keyword_ids][]', '',$list); ?>

        <?php echo CHtml::button('Remove',array('style'=>'display:none;')); ?>

    </div>

    <div class="simple">

        <?php echo CHtml::activeLabelEx($model,'&nbsp;'); ?>

        <?php echo CHtml::button('Add more keywords', array('id'=>'add_more_keywords'));?>

    </div>



this simple changes with simple JS




$(document).ready(function(){

    var b = $('.keyword_container:first');

    var count = 1;


    function addKeyword(){

        var cb = b.clone();

        var el = cb.children('select');

        cb.children('input[type=button]').show().click(removeKeyword);

        count++;

        el.attr('id',el.attr('id')+count);

        $('.keyword_container:last').after(cb);

    }


    function removeKeyword(){

        $(this).parent('div.simple:first').remove();

    }


    $('#add_more_keywords').click(addKeyword);

});



allowed me to dynamically add/remove elements to/from the form

uuu, is too much for me, ha ha ha

see this http://www.yiiframework.com/doc/cookbook/29/

maybe help you

good luck