Stopper
Stopper

Reputation: 411

Post multipart data with Zend Forms

I want to post arrays with Zend.

html form:

    <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 Form:

$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')
        ));

After that, my inputs not displayed. How to make it right? Thanks for help.

Upvotes: 2

Views: 251

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

you could try doing:

$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'
        ),
));

Upvotes: 1

Related Questions