DeadMoroz
DeadMoroz

Reputation: 270

Multiple Zend 1 From elements in single row

I am trying to put two text type inputs in one row with a single label and wrap them in a div representing a row. In a sense I want to go from:

<div class="formRow">
    <label> date to</label>
    <input type="text" name="date" class="dateTimeInput">
</div>

to:

<div class="formRow">
    <label> date to</label>
    <input type="text" name="date" class="dateInput">
    <input type="text" name="time" class="timeInput">
</div>

problem description But I am not sure how to achieve that since the other elements are already inside a display group:

    $customDecorator = array(
        'ViewHelper',
        'Label',
        'Errors',
        array('HtmlTag', array('tag' => 'div', 'class' => 'dialogRow'))
    );

    // date to
    $dateFrom = $this->createElement('text', 'dateFrom', array(
        'label'         => 'date from',
        'decorators'    => $customDecorator,
    ));
    // date to
    $dateTo = $this->createElement('text', 'dateTo', array(
        'label'         => 'date to',
        'decorators'    => $customDecorator,
    ));

    // add first fieldset for shift info
    $this->addDisplayGroup(
        array('dateFrom', 'dateTo'),
        'info',
        array('legend' => 'info')
    );

Any advice will be highly appreciated.

Upvotes: 0

Views: 307

Answers (1)

DeadMoroz
DeadMoroz

Reputation: 270

Solved it on my own by using start/end html tags instead of a wrapper using openOnly and closeOnly options:

    $compositeOpenDecorator = array(
        'ViewHelper',
        'Errors',
        'Label',
        array('HtmlTag', array(
            'tag' => 'div',
            'class' => 'someClass',
            'openOnly' => true,
        )
    ));

    $compositeCloseDecorator = array(
        'ViewHelper',
        'Errors',
        'Label',
        array('HtmlTag', array(
            'tag' => 'div',
            'closeOnly' => true,
        )
    ));

Upvotes: 0

Related Questions