使用Zend Forms发布多部分数据

时间:2013-05-15 09:10:27

标签: php zend-framework zend-form

我想用Zend发布数组。

html表格:

    <form id="form" class="form-container" action="<?php echo $this->form->getAction(); ?>" method="post" enctype="multipart/form-data">
            <?php foreach ($this->projects as $item): ?>
                    <?php echo $this->form->time_on_project; ?>
                    <?php echo $this->form->comment; ?>
            <?php endforeach; ?>

Zend表格:

$this->addElement('text', 'time_on_project[]', array(
            'label' => 'Время(формат час:минуты):',
            'required' => true,
            'attribs' => array('class' => 'form-field', 'required' => 'required', 'placeholder' => 'Введите время в формате час:минуты'))
        );

        $this->addElement('textarea', 'comment[]', array(
            'label' => 'Что сделано:',
            'required' => false,
            'attribs' => array('class' => 'form-field', 'style' => 'height: 100px')
        ));

之后,我的输入没有显示。怎么做对了? 谢谢你的帮助。

1 个答案:

答案 0 :(得分:1)

你可以尝试做:

$this->addElement('text', 'time_on_project', array(
        'isArray' => true,
         'value' => '237',
         'label' => 'Время(формат час:минуты):',
         'required' => true,
         'attribs' => array('class' => 'form-field', 'required' => 'required', 'placeholder' => 'Введите время в формате час:минуты'))
         'decorators' => Array(
             'ViewHelper'
        ),
));